[英]I am trying to build my game in unity but it is giving me an error
Assets/Scripts/ThirdPersonCamera.cs(3,7): error CS0246: The type or namespace name `UnityEditor' could not be found. 资产/脚本/ThirdPersonCamera.cs(3,7):错误CS0246:找不到类型或名称空间名称“ UnityEditor”。 Are you missing a using directive or an assembly reference?
您是否缺少using指令或程序集引用?
im so confused on why i am getting this error..... 我对为什么我得到这个错误很困惑.....
why is this happening? 为什么会这样呢?
This is because UnityEditor namespace is available only in editor scripts, that are located in Assets/Editor
folder; 这是因为UnityEditor名称空间仅在
Assets/Editor
文件夹中的编辑器脚本中可用; or if you are running your game in the editor. 或者您正在编辑器中运行游戏。 If you need some functionality while running your game in the editor, you can do this:
如果在编辑器中运行游戏时需要一些功能,则可以执行以下操作:
#if UNITY_EDITOR
using UnityEditor;
#endif
class Script: MonoBehaviour {
void Update() {
#if UNITY_EDITOR
// Editor specific part here
#endif
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.