I am trying to consolidate the window functions from many windows and executing them from one OnGUI() loop. I have no problems displaying each window, however, I can’t seem to control the order that each window is being displayed.
I was under the impression that by ordering the GUI calls, I would be able to control the order that the GUI elements would be displayed (i.e. elements called later in the loop are drawn on top).
Using the exact same method but drawing GUI.Box instead of GUI.Window seems to work. Does this just not work with GUI.Windows?
The recommended way to get reliable layering of GUI elements is to put each “layer” in a separate script and use the GUI.depth value to set the sorting order. However, there are sometimes additional problems when you use GUI.Window. The GUI layering issues should be improved somewhat in Unity 3.0.
Thanks for the reply. Unfortunately, modifying my method to dynamically set depth values did not work either. Could you take a look at my test project?
Keys Alpha1-4 each open a different window. I need the windows to remain in the order that they were opened, with the most recent window always opening on top. I apologize for the complicated structure of the project, I’m just replicating the structure of the actual game I’m working on.
Unless I’m missing something, you appear to have the class’s depth variable initialised to zero in each script. You need to initialise each to a different value or else make the variable public and set the values in the inspector.