Hide/show GUI Buion

I’m writing a script that when a person clicks a GUI button , it then disappears. How can I do this?

My GUI Code is this.

function OnGUI () {
	GUI.skin = theme;

	
	GUI.BeginGroup (new Rect (Screen.width / 2 - 320, Screen.height / 2 - 240, 640, 480));

    	if (GUI.Button (Rect (10,30,620,30), button1text)) {
    		print("You clicked 1");
    		response = answer1;
    	}
    GUI.EndGroup();
   }

How can I get that button to disappear until the next time the script is activated? So it’s unclickable, not even visible, even. Any ideas?

This will draw a button until the button gets clicked.

You will have to use another script, a button, a timer, or something else to turn it back on.

All you would have to do is set isButtonVisible to true again...

var isButtonVisible  :  boolean  =  true;
var buttonRectangle  :  Rect     =  Rect(100, 100, 100, 50);

function OnGUI ()
{
    /* only draw the button if isButtonVisible equals true */

    if ( isButtonVisible ) {
        if ( GUI.Button(buttonRectangle, "Turn Me Off") ) {
            isButtonVisible = false;
        }
    }
}