use*_*703 1 c# unity-game-engine
Assets/Scripts/ThirdPersonCamera.cs(3,7):错误CS0246:找不到类型或命名空间名称"UnityEditor".您是否缺少using指令或程序集引用?
我很困惑为什么我得到这个错误.....
为什么会这样?
这是因为UnityEditor命名空间仅在位于Assets/Editor文件夹中的编辑器脚本中可用; 或者如果您在编辑器中运行游戏.如果在编辑器中运行游戏时需要某些功能,则可以执行以下操作:
#if UNITY_EDITOR
using UnityEditor;
#endif
class Script: MonoBehaviour {
void Update() {
#if UNITY_EDITOR
// Editor specific part here
#endif
}
}
Run Code Online (Sandbox Code Playgroud)