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 關注
- 588 瀏覽
添加回答
舉報
