Hello, after I included this loop, my game freezes after I click “play button” in my game. Since the “play button” is the big button on “mp3” in the game, I want to make the music play when I click “play” and the animation happen and stop, and after I click it again, music pause and animation happen again and stop. Basically I’m trying to do a non ui button.
I’m a beginner, but can somoene help me out with my code ?
Dont use while loops, really, if you are not very used to use for and foreach, don’t use whiles… you will get in problems like this…
If you think what the code does… It finish the method always as i=0 so it will never exit the while…
And a while inside a while… problems for sure!
If want something repeating, create a IEnumerator, or activate some bool variable that makes the update method execute something every frame, but dont use while for these things… really. Soemthinkg like:
if (Something ==true)
the think to repeat each frame
Something = true;
So once recieve the clik, the update method will execute a code each frame until you change that bool variable again.