I’m using OnGUI and variables. And when I start the game the debug log starts freaking out.
The variable is
private bool Options = false;
This is the code that runs when it’s activated.
if (Options = true;
Debug.Log (“The button works”);
The full code to activate it.
//Options button, Use variables
GUI.backgroundColor = Color.white;
if(GUI.Button(new Rect(Screen.width / 2 - 10,10,60,30),“Options”)) {
Options = true;
audio.PlayOneShot(click);
if (Options == true) Debug.Log (“The button works”);
If you put the Debug.Log method in the if statement, it will always be loggued. Then if you put if (Options = true), it means you first valuate Options to true, and the you test it (so it is always true …). “==” is a test, “=” is to valuate a variable.
And still, at the first button click, Options will be true, forever. There should be something that puts it back to false, because it will never stop displaying “The button works”.