Search Unity

How to acces to a data list in a custom editor from a editorwindow

Discussion in 'Immediate Mode GUI (IMGUI)' started by Phaas, Mar 7, 2019.

  1. Phaas

    Phaas

    Joined:
    Apr 5, 2017
    Posts:
    5
    Hello,

    I customize in the Editor a level editor for my game, i can serialize all my level data parameters in a file.
    I'd like to add an EditorWindow which permit drawing elements, and store in a list in my serialize file below.
    I don't know how to link my CustomLevel class (my editor data manager) with an EditorWindow.

    How to do the link ?

    My custom class managed with the inspector launch correctly the EditorWindow:

    Code (CSharp):
    1.        
    2.  
    3.    if (GUILayout.Button("Open Grid Window", GUILayout.Width(255)))
    4.            {
    5.                GridWindowEditor window = (GridWindowEditor)EditorWindow.GetWindow(typeof(GridWindowEditor));
    6.                window.BeginWindows();
    7.            }
    Inside these class i have a lot of serialized loader and writer.

    My GridWindowsEditor class is something like this :

    Code (CSharp):
    1. public class GridWindowEditor : EditorWindow
    2. {
    3.    public static GridWindowEditor gridWindow;
    4.  
    5.    ==> ??how to get a reference to my custom class (CustomLevel)
    6.  
    7.   private static void OpenWindow()
    8.    {
    9.        GridWindowEditor window = GetWindow<GridWindowEditor>();
    10.        window.titleContent = new GUIContent("Grid Window Editor");
    11.        gridWindow.Populate();
    12.  
    13.    }
    14.    private void OnEnable()
    15.    {
    16.    }
    17.    private void OnGUI()
    18.    {
    19.    }
    20. }
    I'd try a public static CustomLevelEditor refLevelEditor; to reference my target class but i don't know how to instance them.

    Do you have an idea ?

    Thanks.
    Fabb