Turn off my GUI Box when I click a button.

I'm trying to get a script going that will perform different functions based off of the buttons you press. The eventual end result will be; when you click on a door to go to the next scene, it will pop up a box confirming that you'd like to go. If you click yes, It will Load the next level, if you click no, it will simply turn the GUI back off until you click the door again.

I'm trying it out on a box (it should yield the same results in the end game) If you click "yes", it destroys the box... that part works... however, I can't figure out what to do to make "no" turn the GUI off.

function OnGUI() 
{
    GUI.Box(Rect(100,100,300,100),"Would You Like To Destroy This Box?");

    if(GUI.Button(Rect (100,150,100,25),"Yes"))
    {
        Destroy (gameObject);
    }
    if(GUI.Button(Rect(300,150,100,25),"No"))
    {
        //What Goes Here?
    }

}

Any Ideas? Thanks much!

Put "`enabled = false;`" there.

To re-enable, use

function OnMouseUp () {
    enabled = true;
}

This way you don't need extra logic, and the OnGUI function only runs when needed, not all the time.

I think what you want is, to not display anything until a box/door is clicked (rather than disabling the GameObject entirely). Consider re-writing it like this:

var showChoice : Boolean;

function Start() {
    showChoice = false;
}
function OnGUI() 
{
    if (showChoice == false)
        return;
    GUI.Box(Rect(100,100,300,100),"Would You Like To Destroy This Box?");
    if(GUI.Button(Rect (100,150,100,25),"Yes")) 
    {
        Destroy (gameObject);
    }
    if(GUI.Button(Rect(300,150,100,25),"No"))
    {
        showChoice = false;
    }
}
function OnMouseUp() {
    showChoice = true;
}

Create a gameobject and insert your OnGUI() inside of it after some GUI buttons clicked just destroy the game object.

void OnGUI()
	{
		GUI.Box(new Rect(600,300,300,270), "Loader Menu");
		if(GUI.Button(new Rect(650,350,70,30), "EASY"))
		{
			Destroy (this.gameObject);
		}