Hey there,
I wonder if there is anyway I can make a GUI button to disappear.
I have a menu with 6 of them, and each one will show you some options on the same screen of the menu, so I wonder if when I click on one of the main buttons, the options from the other one I pressed earlier can disappear?
I have tried using a bool, but it did not work.
Here is what I have:
using UnityEngine;
using System.Collections;
public class Options : MonoBehaviour {
public Texture MainMenuTexture;
public bool sound = false;
public bool highScores = false;
public bool store = false;
public bool gallery = false;
public bool invite = false;
public bool credits = false;
void OnGUI()
{
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), MainMenuTexture);
if (GUI.Button(new Rect(0, Screen.height * .17f, Screen.width * .2f, Screen.height * .1f), "SOUND"))
{
sound = true;
}
if (GUI.Button(new Rect(0, Screen.height * .30f, Screen.width * .2f, Screen.height * .1f), "HIGH SCORES"))
{
highScores = true;
}
if (GUI.Button(new Rect(0, Screen.height * .43f, Screen.width * .2f, Screen.height * .1f), "STORE"))
{
store = true;
}
if (GUI.Button(new Rect(0, Screen.height * .56f, Screen.width * .2f, Screen.height * .1f), "GALLERY"))
{
gallery = true;
}
if (GUI.Button(new Rect(0, Screen.height * .69f, Screen.width * .2f, Screen.height * .1f), "INVITE"))
{
invite = true;
}
if (GUI.Button(new Rect(0, Screen.height * .82f, Screen.width * .2f, Screen.height * .1f), "CREDITS"))
{
credits = true;
}
}
if (sound)
{
highScores = false;
store = false;
gallery = false;
invite = false;
credits = false;
if (GUI.Button(new Rect(Screen.width * .3f, Screen.height * .17f, Screen.width * .3f, Screen.height * .1f), "YES"))
{
}
if (GUI.Button(new Rect(Screen.width * .7f, Screen.height * .17f, Screen.width * .3f, Screen.height * .1f), "NO"))
{
}
}
if (highScores)
{
sound = false;
store = false;
gallery = false;
invite = false;
credits = false;
}
}
}
Thanks!