Simple Menu(understanding GUI)

I am simply trying to make a small menu that appears for a quit and return to game sequence. I’m not sure what I’m doing wrong… but I’d like it if I could have some help fixing or understanding why nothing appears :slight_smile: I currently have it attached to an invisible game object that the camera follows along.

> function Update () {
> if(Input.GetKeyDown(KeyCode.Escape))
> 	{ 	 	menuButtons();
> 
> 	 	 	} }
> 
> 
> function menuButtons(){ var
> labelOptions = GUILayout.Width(90);
> GUI.Button(Rect(25,25,100,30),"Quit");
> 
> if(GUILayout.Button("Quit")) 	{
> 		Application.Quit(); 	} 	 }

You need an OnGUI function I think. The way I do this is with booleans, it may not be quite right but try this out:

var escPressed : boolean;

function Start(){
escPressed = false;
}

function Update () {
if(Input.GetKeyDown("esc")){
escPressed = true;
  }else{
escPressed = false;
 }
}
        
         
         
function OnGUI(){
if(escPressed == true){
labelOptions = GUILayout.Width(90);
GUI.Button(Rect(25,25,100,30),"Quit");
   }
}

Try this.

var escPressed : boolean;

function Update () {
if(Input.GetKeyDown("esc")){
escPressed = true;
    }
}

function OnGUI(){
if(escPressed == true){
labelOptions = GUILayout.Width(90);
GUI.Button(Rect(25,25,100,30),"Quit");
    }
}