Button Turns Off and On Object

I’ve successfully created a code to turn off an object when a button is pressed. That being said I want to be able to press the button again to turn the object back on. (possible even to change color to indicate when it is on or off)

Unfortunately when I press the button the object disappears (which is good) but the button disappears too (which is bad) . what can I add to my script to accomplish the above.
Thanks for your help :slight_smile:
using UnityEngine;
using System.Collections;

public class ButtonGuiScript : MonoBehaviour {

	// Use this for initialization
	void Start () 
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
	
	}
	private void OnGUI()
	{
		if(GUI.Button(new Rect(15, 15, 100, 50), "West Wind Zone"))
		{
			gameObject.SetActive(false);
		}

		
		
	}

}

or just

cube.SetActive(!cube.gameObject.activeSelf);

depending on whether you prefer shorter code or less variables

Standard way to do this is

bool isOn;

private void OnGUI(){
    if(GUI.Button(new Rect(15, 15, 100, 50), "West Wind Zone")){
         isOn = !isOn;
         gameObject.SetActive(isOn);
    }    
}