how can i make my pause menu switch menus?

i have my pause menu all designed how i want it, plus a restart level and a resume button, but my next 2 buttons are “Options” and “Character Setup” which is dealing with hiding the buttons on the main pause screen and showing the other buttons for the selected menu. im trying to use booleans to trigger when menu’s are showing or not, but when i press the “X” button to open the Options menu none of the buttons hide and no other buttons show up. how can i fix this, or is there another way i could switch menu’s?

private bool mainPause;
private bool optionPause;

void OnGUI() {

mainPause = true;
optionPause = false;

if (mainPause == true){

/////////////////////X Button////////////////////////////////////////////

    if(GUI.Button(new Rect(Screen.width*.045F, Screen.height*.2F,  Screen.width.2F, Screen.height.025F), "Options")){

        mainPause = false;
    optionPause = true;     
        }
    GUI.EndGroup();
}
else if (optionPause == true){
/////////////////////Y Button////////////////////////////////////////////

    if(GUI.Button(new Rect(Screen.width*.15F, Screen.height*.1F, Screen.width.2F, Screen.height.025F), "Restart Level")){

        Application.LoadLevel("Training Layout");
        Time.timeScale = 1.0f;
        player.GetComponent<MouseLook>().enabled = true;
        cam.GetComponent<MouseLook>().enabled = true;
        cam.GetComponent<ShowSkin>().enabled = false;
        }

GUI.EndGroup(); 
}
}

this is a shortened version of my code, i took out unnecessary buttons that wouldn’t effect anything. if you want me to post up the full script let me know…

any help is appreciated

Using an enum to monitor state might work out better for you.

private enum uiStates { PAUSE, OPTIONS, CHARSET };
private uiStates myState = uiStates.PAUSE;

void OnGUI()
{
     if (myState == uiStates.PAUSE)
     {
          // draw pause menu
     }
     else if (myState == uiStates.OPTIONS)
     {
          // draw options menu
     }
     else if (myState == uiStates.CHARSET)
     {
          // draw character setup
     }
}

haha yeahh thanks xD it worked perfectly so far. im just gonna have to make another one for my gamepad’s controlls under void Update ();

thanks a lot :slight_smile: