A while ago I made the code for a GUI menu which I unfortunately lost, so I’ve had to start again. This time though, I’m using the GUI.Window system, which I hadn’t noticed before (previously I’d used Boxes). However when running the program either in the Editor or as a standalone, only the Quit button is drawn. If I click that, the appropriate Debug messages appear, but it doesn’t seem to draw the Windows. So how can I get this to work properly? The answer’s probably staring me in the face, but I’d really appreciate an answer.
Code:
#pragma strict
var miniWindowDimensions : Rect = Rect((Screen.width/2)-(Screen.width/10),(Screen.height/2)-(Screen.height/10),Screen.width/5,Screen.height/5);
public var close : Texture;
public var freezeLayerOne : boolean = false;
function OnGUI()
{
if(GUI.Button(Rect(Screen.width*0.6, (Screen.height/20)*18, Screen.width/3, Screen.height/10), "QUIT") && freezeLayerOne == false)
{
print("Quit pressed");
freezeLayerOne = true;
GUI.Window(0,Rect(miniWindowDimensions),sureQuitCreate,"Are you sure?");
}
}
function sureQuitCreate(windowID : int)
{
if(GUI.Button(Rect((Screen.width/2)+(Screen.width/20)*15,(Screen.height/2)-(Screen.height/10)+2,20,20),close))
{
freezeLayerOne = false;
print(freezeLayerOne);
}
if(GUI.Button(Rect(0,0,40,40),"QUIT"))
{
Application.Quit();
}
}