2 回答

TA贡献1794条经验 获得超8个赞
你现在有错误的原因是,Unity 在编译时删除了他们为它设计的“UnityEditor”命名空间。这就是为什么当您尝试在平台上使用它时,“EditorUtility”将永远不会存在于除 UnityEditor 之外的任何平台上。因为“EditorUtility”在“UnityEditor”命名空间中。
因此,如果您想使用“EditorUtility”完成与在 Unity 编辑器中所做的相同的工作,您应该像他们一样自己实现它。
#if UNITY_EDITOR
EditorUtility.DisplayDialog("Great!", "You got the pattern right!", "Next Level!");
#else
YOUROWNCLASS.DisplayDialog("Great!", "You got the pattern right!", "Next Level!");
#endif

TA贡献1982条经验 获得超2个赞
UnityEditor
内容通常只能在编辑器中使用,因为在将游戏构建为独立 EXE 时不能使用它。
如果您实际上是为编辑器编译游戏,请尝试添加预处理器指令以仅包含与编辑器相关的内容。
#if UNITY_EDITOR EditorUtility.DisplayDialog("Great!", "You got the pattern right!", "Next Level!"); #endif
正如@Retired Ninja 在评论中告诉我们的那样,您还需要#if UNITY_EDITOR ... #endif
在您的行周围放置相同的指令。using UnityEditor;
- 2 回答
- 0 关注
- 382 浏览
添加回答
举报