UI Window inside another window

There is a way to get a GUILayout.Window inside another GUILayout.Window?

I tried:

menuPrincipal = GUILayout.Window(0, menuPrincipal, ventana_menu,"Menu", GUILayout.Width(Screen.width - 80),GUILayout.Height(Screen.height - 80));

function ventana_menu(id : int) {
	GUILayout.BeginHorizontal();
	//Primera fila
	if(GUILayout.Button("Ajustes")){
		GUILayout.Window(1, menuOpciones, ventana_ajustes,"Sensibilidad", GUILayout.Width(Screen.width - 80),GUILayout.Height(Screen.height - 80));
	}
	GUILayout.EndHorizontal();
}

But sends me an error:

GUI Error: You called GUI.Window inside a another window’s function. Ensure to call it in a OnGUI code path.
UnityEngine.GUILayout:Window(Int32, Rect, WindowFunction, String, GUILayoutOption)
interfaz:ventana_menu(Int32) (at Assets/Scripts/interfaz.js:94)
UnityEngine.GUI:CallWindowDelegate(WindowFunction, Int32, GUISkin, Int32, Single, Single, GUIStyle)

Where I can find information about “OnGUI code path”?

Thanks, sorry my english.

Make the call to your second window from within void OnGui() {}.

In your first one, have the selection of the button set a boolean variable to “true”, that is initialized to “false” to start, and upon closing that window gets reset to “false”.

Thus something similar to:

private bool openMenuOpciones = false;

void OnGui()
{
  //open the first menu window here .. as you must already have in the code
...
  //open the second menu window if it was triggered
  if (openMenuOpciones)
     GUILayout.Window(1, menuOpciones, ventana_ajustes,"Sensibilidad", GUILayout.Width(Screen.width - 80),GUILayout.Height(Screen.height - 80));

}

 function ventana_menu(id : int) {
GUILayout.BeginHorizontal();
//Primera fila
if(GUILayout.Button("Ajustes")){
 openMenuOpciones = true;
 }
GUILayout.EndHorizontal();
}

The new UI system in Unity 4.6 / 5.0 is much easier to use imo. Especially when it comes to things like you are trying to do. :slight_smile: