Can't Get my 2nd Window to Open..

here’s my script,I’m only new here,

var wind1 : Rect = new Rect(65,10,120,60);
var wind2 : Rect = new Rect(120,10,100,50);
var Win1 = false;
var Win2 = false;

var button1 : Rect;
var button2 : Rect;
var button3 : Rect;
var buttonc : Rect;
var buttonl : Rect;

var cr8 = true;
var lod = false;

function OnGUI()
{
wind1 = GUI.Window(0,wind1,StartGame,“MMONSG”);
}

function StartGame(windowID : int)
{ GUI.Button(button2,“OPTIONS”);
GUI.Button(button3,“QUIT”);

if(GUI.Toggle(button1,Win1,"START GAME","button"))
		{
		 Win1 = true;
		 wind2 = GUI.Window(1,wind2,CreatePlayer,"LOLO");
 		}
 		else
 		{
 		Win1 = false;
 		}

}

function CreatePlayer(windowID : int)
{

GUI.Button(buttonc,"CREATE");
GUI.Button(buttonl,"LOAD");

}

First, welcome :slight_smile:

  • Then, I’m not sure you can call a window from another window function. Maybe you’ll need to call them both from OnGUI.
  • And I think you need to store the window ID in a variable (the 0 and the 1).
  • Finally, GUI.Toggle return a bool, so you can do Win1 = GUI.Toggle(…)

thanks! finally got the idea :slight_smile:


function StartGame(windowID : int)
{
GUI.Button(button2,“OPTIONS”);
GUI.Button(button3,“QUIT”);

if(GUI.Toggle(button1,Win1,"START GAME","button"))
		{
		 Win1 = true;
		 wind2 = GUI.Window(1,new Rect(120,10,100,50),CreatePlayer,"LOLO"); // i just set the rect instead of calling the var
 		}
 		else
 		{
 		Win1 = false;
 		}

}

and thanks for the advice :slight_smile: