- Home /
GUI Button Enable/Disable
Hello, i have this fullscreen of or on button thing and i want it to if the player clicks "<" then the button "<" disables, and if someone click ">" then the "<" enables and the ">" disables (you understand more if you see the code) here is the code:
if (GUI.Button(new Rect(Screen.width / 2 - 40, Screen.height / 2 - 80, 50, 25), "<"))
{
audio.PlayOneShot(buttonsound);
fullscreentext = "No";
Screen.fullScreen = false;
}
if (GUI.Button(new Rect(Screen.width / 2 - -100, Screen.height / 2 - 80, 50, 25), ">"))
{
audio.PlayOneShot(buttonsound);
fullscreentext = "Yes";
Screen.fullScreen = true;
}
Answer by tw1st3d · Oct 08, 2013 at 06:41 PM
Could do it like this.
public class Test : MonoBehaviour
{
public int activeButton = 1;
public void OnGUI()
{
if(activeButton == 1)
{
if(GUI.Button(new Rect(Screen.width / 2 - 40, Screen.height / 2 - 80, 50, 25), "<"))
{
audio.PlayOneShot(buttonsound);
activeButton = 2;
}
}else if(activeButton == 2){
if(GUI.Button(new Rect(Screen.width / 2 - -100, Screen.height / 2 - 80, 50, 25), ">"))
{
audio.PlayOneShot(buttonsound);
activeButton = 1;
}
}
}
}
I mean making the button tranparent, like GUI.enable = false; (but i dont know how to set it up if you know what i mean)
No, not entirely. Do you mean both are visible at first, then when you click one, that one becomes partially transparent?
The "<" is visible and the ">" is tranparent at the first then when i click "<" it becomes transparent and the ">" becomes visible
Your answer

Follow this Question
Related Questions
gui text button dont work 1 Answer
Create 3D GUI Button? 2 Answers
GUI click through? 3 Answers
Button onClick events will not be triggered 1 Answer
Embed GUI Skin in GUI Button 2 Answers