I’ve run into a big wall which I have yet to understand, and that is why I’ve come to you guys.
I’ve already posted my question on Unity Answers, but I wanted to get more feedback as to what’s happening, so if you have the time, please help me out. Its driving me insane…
Basically, the script just creates 4 buttons, for the sake of length and readingness I just added the code for one button, which in this case is UP.
When I press it, I made a function OnGUI that checks if its being pressed.
Now, WHILE its being pressed the Debug Statements are off…
Line1: A Button is Active!
Line2: No button is active…
Line3: A Button is Active!
Line4: No button is active…
NOTE that the button was never unclicked…
Thanks for your help and time, I know its very precious to you.
I actually eliminated the variables, changed the names (and added new ones,UpActive…) there’s only 1 place it’s modified and its just what the button returns…so I could see where its set to false…
The problem is that it gets executed several times. You can check it e.g. by also showing Event.current, which will tell you that first the layout is handled and then the actual repainting takes place. Only during the repainting, you are going to get the correct answer.
If you show the value e.g. in Update or any other place than OnGUI, you are going to get the correct result. The problem is that you are using and else for the GUI.RepeatButton. This does not work with an immediate gui solution.
@Dantus
Sorry for the improper way to add the code.
Thanks for your time and help. And yes, you rock.
I just moved everything. Creating the button on OnGUI and checking if they’re pressed on Update() and it worked.
If you don’t mind, I’ll add your answer to the question on Answers U.