- Home /
how to quit the application in the editor of u3d?
if a script has a endless loop,when i use play mode,the unity may get dead,how can i stop the script?
and when i debug the program,how can i quit the application in the source code.i try to use Application.Quit().but the manual says that: Quits the player application. Quit is ignored in the editor or the web player.
so are there some else methods to quit?
Answer by tanoshimi · May 10, 2016 at 06:04 AM
I don't think you want to quit the editor, just to stop play mode.
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
but is there some button in editor to stop the play mode. Because sometimes i may not find some problems such as a endless loop,then if i choose to play,i can not quit unless to quit unity thread forcely.
The button in the editor to stop play mode is the big blue play button at the top of the screen. If you've created an infinite loop, such as by writing while(true) {i++}
in your Update(), then there's not much you can do - your program loop will continue to iterate over that tiny little block so it won't ever get a chance to listen for events such as keypresses or break commands. If you think you might be about to create an infinite loop, make sure to save your scene before you hit play. And don't use while() unless you're sure that an exit condition can be met.