I have a simple custom editor window, which displays an asset. The asset is a class which is derived from scriptable object and holds a list of third base class. A simplified version: Code (csharp): using System; using UnityEngine; using UnityEditor; [Serializable] public class BaseClass { public int someValue; public void OnGUI() { // EditorGUILayout Stuff - THIS IS THE PROBLEM RIGHT HERE } } Code (csharp): using System.Collections.Generic; using UnityEngine; public class ListContainer : ScriptableObject { public List<BaseClass> m_List; void OnEnable() { //First check if this a new ScriptableObject or one which has been deserialized if (m_Listt == null) { // Just initializing the list with a single entry m_List = new List<BaseClass>() { new BaseClass() }; } } public void OnGUI() { // Show each item in the list: for (int i = 0; i < m_List.Count; i++) { m_List[i].OnGUI(); } } } Code (csharp): using UnityEngine; using UnityEditor; public class LevelEditor : EditorWindow { private ListContainer m_ListContainer; [MenuItem("GameAssets/LevelsList")] static void Init() { var window = GetWindow<LevelEditor>(); } void OnGUI() { m_ListContainer.OnGUI(); } } The problem stems from the fact the I want the containing list and the base class, to display EditorGUILayout derived functions(being responsible for their own display in the custom editor window)...While this works for running the project in Unity editor... It fails on builds. The error reported is : type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference? I understand this is due to the fact that I am not keeping the base level class and the ListContainer class in the "Editor" folder. So what would be the right way of getting this done...Basically I am asking how can I have members which belong to an editor window be responsible for their own appearance in the editor window using EditorGUI /EditorGUILayout methods, while retaining their availability to other scripts outside the "Editor" folder.
Since editor's solution has references to the mail solution, I think, it is imposible to have a reference from editor's solution to main. But I think, there should be a workaround...
No, its because UnityEditor and all its related classes are not included in a build. You can use the #if UNITYEDITOR preprocessor to stop the errors, but any code that you expect to run in-game just won't ever.
So from these answers am I to conclude that all the graphical representation of members of an EditorWindow derived class which use EditorGUILayout/EditorGUI must be done in a script which MUST reside in the "Editor" folder?