- Home /
 
Can EditorWindows dynamically display interfaces of other Editor Windows ?
For example , we create an editor window named DisplayWindow which displays 3 buttons inside it. the buttons are Inspector button Hierarchy button Scene button
How can we make it so that when we click the Heirachy button , DisplayWindow repaints to display the Heirachy editor window interface ?
when we click the Inspector button , DisplayWindow repaints to display the inspector editor window interface ...etc
Can this be done ? , if it can , then should it be done or is it just going to be slow and taxing on the CPU?
Or should I just pool everything into one script and just make a GUI interface from which i can cycle through the different GUI interfaces ?
Answer by Tomer-Barkan · Apr 14, 2015 at 07:56 PM
You can put all the lines of code that create the window display in a single public function, then you can call that function from within the DisplayWindow OnGUI() and from the specific window OnGUI(), and they will all draw the same thing.
 // HierarcyEditor
 private void OnGUI() {
     DrawWindow();
 }
 public static void DrawWindow() {
     EditorGUILayout.BeginVertical();
     // layout stuff goes here
     EditorGUILayout.EndVertical();        
 }
 // Display Window
 private bool displayHierarchy = false;
 private void OnGUI() {
     if (GUILayout.Button("Hierarchy")) {
         displayHierarch = true;
     }
     if (displayHierarchy) {
         HierarchyEditor.DrawWindow();
     }
 }
 
               That's the idea, you'll need to tweak the script for your exact needs.
okay I understand this . The issue i'm having now is that I am using a rather complex framework for the editor window , the bigger the framework of the editor window , the slower it becomes once I use this method .
I think that in the end I may have to just have one huge editor script. but thanks to this I have a good idea of how to proceed .
I'm going to wait and see if someone else have another answer before i mark this as correct seeing as it is not 100%
Your answer
 
             Follow this Question
Related Questions
Can not close editor window not in GUILayout.somemethod in OnGUI method 0 Answers
How to trigger button press on a button in an editor window by pressing the return key ? 0 Answers
How do I use GUI.BeginCLip() ? There is no documentation on docs.Unity 1 Answer
Can't find proper use of objectfield in a custom editor window (C#) 0 Answers
Distribute terrain in zones 3 Answers