简体   繁体   English

我正在尝试统一构建游戏,但这给了我一个错误

[英]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.

相关问题 我正在尝试为我的 Unity 游戏编写一个重置按钮 - I am trying to code a reset button for my Unity game 我正在努力让我的 Unity 游戏在游戏结束后重新启动 - I am trying to make it so that my Unity game restarts after the game has ended 我正在尝试使用 Unity 制作 FPS 足球游戏,但我的脚本不起作用 - I am trying to make an FPS soccer game using Unity, but my script isn't working 我正在尝试将Unity游戏连接到MongoDB,但是使用异步方法和任务时出现错误,我该如何解决? - I am I am trying to connect Unity game to MongoDB but I have an error using an a async method and task, How can I solve that? 我正在尝试在C#中执行以下代码,但是以某种方式给我一个错误 - I am trying to execute the following code in C# but its somehow giving me an error 我试图在unity-webGL中构建游戏,但出现错误 - I tried to build my game in unity-webGL and I got an error 使用Auth0运行WeGL Unity游戏的构建时出错 - Error while running build of my WeGL Unity Game with Auth0 我应该为构建iOS游戏加密我的Unity代码吗? - Should i encrypt my Unity code for build IOS game? 在 2D Unity 游戏中使用 C# 时出现错误,说我的 5 个名字“在当前上下文中不存在” - I am getting an error when using C# in a 2D Unity game, saying that 5 of my names "does not exist in the current context" 我正在用统一引擎制作 2d 平台游戏,但我无法让我的玩家跳跃 - I am making a 2d platformer game in unity engine, but I am unable to make my player jump
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM