- Home /
Application.Quit needs to be called twice?
I have a simple Quit button in my game that calls Application.Quit. And it works. Except you have to hit it twice. I can log and see that the button is being pressed twice, and it appears application.quit is called twice.
I do have a couple of game objects with OnApplicationQuit() methods; they are used to save the game and to save the user's preferences when they quit the game. They are successfully invoked (twice).
I've searched around a lot and can't seem to find anyone having a similar problem.
I'm not doing this from the editor either :)
Hi, do you call Application.CancelQuit() on the body of any $$anonymous$$onobehaviour.OnApplicationQuit() ??? This might explain why it has to call Application.Quit() twice in order to really finish the process.
No gameobjects should exist at the point that OnApplicationQuit is called, I do believe, as OnDestroy runs before it, which marks the destruction of all the objects. Do you have some gameobject being created in OnDestroy?
@meat5000: do you know any reference for the order in which these events take place ??
I'm trying to open a confirm quit dialog using Application.CancelQuit() at the body of $$anonymous$$onobehaviour.OnApplicationQuit. It turned out badly.
Found it yesterday, thanks a lot! Will try native OS functions and a lot of workarounds for my case.