Unity: Ошибка The type or namespace name UnityEditor could not be found

При попытке собрать проект через File -> Build & Run получаю несколько ошибок:

Assets/Scripts/MonoBehaviours/AI/StateController.cs(3,7): error CS0246: The type or namespace name `UnityEditor’ could not be found. Are you missing an assembly reference?

Error building Player because scripts had compiler errors

Build completed with a result of ‘Failed’
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors
at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:181
at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00065] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:88
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Ошибки связаны практически с ОДНОЙ строчкой :)

В один из файлов мне потребовалось добавить следующую строку:

using UnityEditor;

она нужна была для этого фрагмента кода:

Selection.activeObject = gameObject;
EditorGUIUtility.PingObject(gameObject);

Поскольку это нужно было только во время отладки, то для того, чтобы исправить ошибку, пришлось немного изменить код:

#if UNITY_EDITOR
  using UnityEditor;
#endif

Точно также для двух других строчек:

#if UNITY_EDITOR
  Selection.activeObject = gameObject;
  EditorGUIUtility.PingObject(gameObject);
#endif


Подписаться
Уведомление о
guest
0 Комментарий
Inline Feedbacks
View all comments