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
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);
}
}
}