错误是:
Trying to create a material from string - this is no longer supported.
UnityEngine.Material:.ctor(String)
Drawer:CreateLineMaterial() (at Assets/Flying Birds/Scripts/Drawer.cs:27)
Drawer:Awake() (at Assets/Flying Birds/Scripts/Drawer.cs:46)
Run Code Online (Sandbox Code Playgroud)
第 27 行是:
var mat = new Material(
Run Code Online (Sandbox Code Playgroud)
第 46 行:
lineMaterial = CreateLineMaterial();
using System;
using UnityEngine;
using System.Collections.Generic;
public class Drawer: MonoBehaviour
{
public Material lineMaterial;
struct Line
{
public Vector3 from;
public Vector3 to;
public Color color;
public Line( Vector3 from, Vector3 to, Color color )
{
this.from = from;
this.to = to;
this.color …Run Code Online (Sandbox Code Playgroud) 这是我的脚本,我试图制作"",以防它不是其中一个案例:
using UnityEngine;
using System.Collections;
public class DetectPlayer : MonoBehaviour {
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Platform")
{
Debug.Log("Touching Platform");
}
else
{
Debug.Log("");
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "OnTop Detector")
{
Debug.Log("On Top of Platform");
GameObject findGo = GameObject.Find("ThirdPersonController");
GameObject findGo1 = GameObject.Find("Elevator");
findGo.transform.parent = findGo1.transform;
}
else
{
Debug.Log("");
}
}
}
Run Code Online (Sandbox Code Playgroud)
但这""不起作用.在游戏运行时,它不会从控制台中删除文本.而且当我停止游戏并再次运行它时,它会继续显示Debug.Log的最后一个文本.
如果在我的脚本中没有发生If,我想清除它.
我看到了这个答案:
但我不确定这是否是我需要的以及如何使用它.制作一个新剧本?
还有错误呢.如果我清除登录控制台,它会删除erorrs,如果有一些?
在这个屏幕截图中,我触摸平台然后离开它后处于状态,但文本仍然存在于控制台日志中:
我运行统一5.3.4p4版本.但是我得到一个错误,如请求错误(错误):UnityEditor.AsyncHTTPClient:完成(状态,Int32)几天,而我打开统一.
虽然它现在没有造成任何问题,但我想摆脱这个错误.
这个错误的解决方案是什么?
我有Tiled2Unity插件.当我开始在Unity中构建我的游戏版本时,无论是独立版本还是其他任何东西,我都会收到以下错误:"构建播放器时出错,因为脚本在编辑器中存在编译错误"
然后它指向我这堂课
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
namespace Tiled2Unity
{
public class CircleObject : TmxObject
{
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我弄清问题是什么?
我想知道是否有办法获得线渲染器中节点的位置。在我正在处理的项目中,我有一个PseudoLine游戏对象,在该对象上有一个线条渲染器。当我画一条线时,我会克隆PseudoLine以创建一条新线。简单地使用:
Instantiate(gameObject);
Run Code Online (Sandbox Code Playgroud)
我想要做的是使用预制件创建新的游戏对象,该预制件上还有一个线渲染器。我想将 的位置复制PseudoLine到我的新游戏对象的线条渲染器。像这样的东西:
GameObject tempLine = Instantiate(line);
tempLine.GetComponent<LineRenderer>().SetPositions(transform.gameObject.GetComponent<LineRenderer>().Positions);
Run Code Online (Sandbox Code Playgroud)
我检查了文档,找不到任何有用的内置函数。我该如何解决这个问题?
Unity的Raycast函数有一个参数可用于光线投射到特定的GameObject.您还可以使用该参数来忽略特定的GameObject.
例如,Raycast功能:
public static bool Raycast(Vector3 origin, Vector3 direction, float maxDistance = Mathf.Infinity, int layerMask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);
Run Code Online (Sandbox Code Playgroud)
该layerMask参数用于指定哪些对象应该/不应该接收光线投射.
1.如何光线投射到名为"立方体"的图层中的特定 GameObject?
2.如果你在场景中有10个 GameObjects,但是你只想光线投射到2个 GameObjects并忽略其余的那些?你是怎样做的?
假设那些对象的层是"立方体"和"球体".
3.如果你想要对所有 GameObjects 进行光线投射但忽略1,那该怎么办?
假设要忽略的GameObject位于"立方体"层中.
4.如果你想要对所有 GameObjects 进行光线投射但忽略2个(多个)GameObjects,那该怎么办?
同样,要忽略的层是"立方体"和"球体"层.
该文档说明了iOS/Windows版本中使用的标识符,而不是Android版本.SystemInfo.deviceUniqueIdentifier在Android 上使用什么标识符?
我刚刚在Android上尝试了我的应用程序,它突然无法正常工作(在Windows上运行正常).有没有办法看到统一控制台的错误和Debug.Log消息 - 当我在Android上运行设备?(我使用开发模式和脚本调试).
我将adb连接到设备,也可以使用logcat和filter来"统一",但它仍然显示一个疯狂的日志.
我想看到的只是一个干净的日志,显示错误和我的Debug.Log消息,我通常可以在Unity上的Unity控制台上看到简单明了.
我在移动2D统一游戏中有多个场景,我想在启动画面中加载我的所有场景,以便场景传递顺畅.我怎样才能做到这一点 ?
如果我这样做,我是否需要更改"Application.LoadScene()"方法,我可以使用哪种方法?
我正在尝试编写一个脚本,当你击中敌人时它会播放声音,问题是我无法让它播放它看到音频源的声音,但我的脚本不会将剪辑传递给它。
这是我目前拥有的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class makeanoise : MonoBehaviour
{
public AudioClip hurtSound;
public AudioSource soundSource;
private void Update()
{
if (!soundSource.isPlaying)
{
soundSource.clip = hurtSound;
soundSource.Play();
}
}
}
Run Code Online (Sandbox Code Playgroud)
你如何让音频源播放声音?因为连我的队友都不知道这样做