I just made a silly mistake and inside the void Update()
instead of writting an if(var)
I wrote while(var)
and the var
was never modified inside the while, so I ended up programming an infinite loop inside my Update()
The story itself is not really important. The important thing is I wasn´t able to stop the Play Mode. Actually I wasn´t able to do anything else with Unity until I restarted.
So my question is, does anyone know how to stop the Play Mode in Unity gracefully? Is there any shortcut or some lines of code to force a timeout?
I know the best way is to avoid infinite loops, but somethings you can make a silly typo.
Extra Note: I have been looking for a solution to this issue for a while, unfortunately without success. However I found a solution to a side-effect of this problem. When you press ctrl-alt-del you can loose everything you haven´t save in your scene (which can be hours of work).
So Unity does an auto-save when you hit play, and the scene backup is in the Temp folder
, as long as you haven´t run Unity again after a force-quit.
Click the play button to exit Play mode.
The following worked for me (Props to @LinusR and by extension @Kinxil) This is just a quick step-by-step.
[LinusR's solution seemed to be the most bullet-proof and versatile.]
Thread.SpinWait.SpinUntil(() => someObject.NeverTrue());
someObject = null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With