Main menu help needed (C#)

So i am making a Main Menu in C# and it does not work properly

using UnityEngine;
using System.Collections;

public class MainMenu : MonoBehaviour 
{
	private bool Options = false;

	void OnGUI()
	{
		if(Options == false)
		{
		GUI.Box (new Rect(0,0,Screen.width, Screen.height),"Main Menu");
		if(GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-260, 100, 25),"Singleplayer"))
		{
			Application.LoadLevel(2);
		}
			if (GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-230, 100, 25), "Multiplayer")) 
		{
			Application.LoadLevel (1);
		}
			if (GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-200, 100, 25), "Quit game")) 
		{
				GUI.Label (new Rect(Screen.width/2 -50, Screen.height/2- 220, 100, 25), "Are you sure?");

				if(GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-200, 100, 25), "Yes"))
				{
					Application.Quit();
				}

				if(GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-170, 100, 25), "No"))
				{
					Application.LoadLevel(0);
				}

		}
			if (GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-170, 100, 25), "Options"))
		{
			Options = true;
		}
			if (Options == true) 
			{
				GUI.Box (new Rect(0,0,Screen.width, Screen.height),"Options Menu");
				if(GUI.Button (new Rect(Screen.width/2 -45, Screen.height/2-260, 100, 25), "back"))
				{
					Options = false;
				}
			}
		}
	}

}

so when I press Quit Game nothing happends
and when I press Options it just goes black and
the back button does show up.
I don’t know what’s wrong so please help me.

I am not an expert on the area, but i made a main menu like this, except for the quit game. I think you have to rearrange your levels so the Main Menu is one of the first ones, but i will link you my main menu so you can see for yourself.

	void OnGUI () {
		if (GUI.Button(new Rect( 20, 20, 150, 100 ), "Level 1", myStyle)){
			Application.LoadLevel ("Level1");	
		}

		if (PlayerPrefs.GetInt ("highScore1") < 5000){
			GUI.Box(new Rect( 20, 140, 150, 100), "Level 2 

Score 5000
in Level 1
to unlock!",myStyle2);
}

		if (PlayerPrefs.GetInt ("highScore2") < 5000){
			GUI.Box(new Rect( 20, 260, 150, 100), "Level 3 

Score 5000
in Level 2
to unlock!",myStyle2);
}

		if (PlayerPrefs.GetInt ("highScore1") > 5000){
			if (GUI.Button(new Rect( 20, 140, 150, 100), "Level 2",myStyle)){
				Application.LoadLevel ("Level2");	
			}
		}

		if (PlayerPrefs.GetInt ("highScore2") > 5000){
			if (GUI.Button(new Rect( 20, 260, 150, 100), "Level 3",myStyle)){
				Application.LoadLevel ("Level3");	
  			}
        }
    }

Alright so what i have done here is that if my score in level 1 is over 5000 points, the GUI.Box will disappear and a button will be there instead, so that i can access level 2. Meaning that i have multiple levels that unlocks after how many points i get.

You see, the GUI is drawn every frame in the OnGUI() method. So if you want it displayed, you need to call the GUI.Button() etc every frame.

Now the problem is here:

if (GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-200, 100, 25), "Quit game")) 
{
	GUI.Label (new Rect(Screen.width/2 -50, Screen.height/2- 220, 100, 25), "Are you sure?");

	if(GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-200, 100, 25), "Yes"))
	{
		Application.Quit();
	}

	if(GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-170, 100, 25), "No"))
	{
		Application.LoadLevel(0);
	}
}

You see, in the frame when the button is pushed, it goes into the if and desplays the are you sure message. But that is a single frame, in the next frame, the button is no longer pressed, so the dialog no longer appears.

The way you can do it, is when the button is clicked, set some class variable to true, that way it remains true until you decide otherwise (until the user clicks yes or no):

Here’s the code:

public class MainMenu : MonoBehaviour 
{
	private bool Options = false;
	private bool quit = false;

	void OnGUI()
	{
		if(!Options && !quit)
		{
			GUI.Box (new Rect(0,0,Screen.width, Screen.height),"Main Menu");
			if(GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-260, 100, 25),"Singleplayer"))
			{
				Application.LoadLevel(2);
			}

			if (GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-230, 100, 25), "Multiplayer")) 
			{
				Application.LoadLevel (1);
			}

			if (GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-200, 100, 25), "Quit game")) 
			{
				quit = true;
			}
			
			if (GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-170, 100, 25), "Options"))
			{
				Options = true;
			}
		} 

		if (quit)
		{
			GUI.Label (new Rect(Screen.width/2 -50, Screen.height/2- 220, 100, 25), "Are you sure?");

			if(GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-200, 100, 25), "Yes"))
			{
				quit = false;
				Application.Quit();
			}

			if(GUI.Button (new Rect(Screen.width/2 -50, Screen.height/2-170, 100, 25), "No"))
			{
				quit = false;
				Application.LoadLevel(0);
			}
		}
		
		if (Options)
		{
			GUI.Box (new Rect(0,0,Screen.width, Screen.height),"Options Menu");
			if(GUI.Button (new Rect(Screen.width/2 -45, Screen.height/2-260, 100, 25), "back"))
			{
				Options = false;
			}
		}
	}
}