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 ?
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.