- Home /
Unity 3D C# - Buttons Need TO Press More Then Once
This is my code for the GUI buttons
if (Gameplay == false) {
if (GUILayout.Button ("Play Easy")) {
Gameplay = true;
}
if (GUILayout.Button ("Play Medium")) {
Gameplay = true;
}
if (GUILayout.Button ("Play Hard")) {
Gameplay = true;
}
if (GUILayout.Button ("Play ASIAN")) {
Gameplay = true;
}
if (GUILayout.Button ("Quit")) {
Debug.Log ("Clicked Button");
}
}
What is meant to happen is when I press one of those buttons the GUI is meant to away, but what is odd, is I need to press one of the buttons 5 times before it will work and there are 5 buttons making me think the buttons are rendered 5 times, can some one please help? what have I done wrong?
Comment
Best Answer
Wiki
Answer by Kiwasi · Jun 09, 2014 at 07:56 AM
Check that you do not have multiple copies of the script floating around. Is it on more then one GameObject with the component attached? Or is the component duplicated on a single GameObject?
Your answer
Follow this Question
Related Questions
GUI.Button press (not click) 3 Answers
On-screen button press 1 Answer
gui.button down 2 Answers
Move GUI elements. 0 Answers