- Home /
if Application.wantsToQuit return false but the OnApplicationQuit also will be invoked
When player close the game, I want to do something before the game exiting like save the game data.So I register an function into "Application.wantsToQuit" and return false to prevent the game exiting. It works well. But even the function in "Application.wantsToQuit" return false and the "OnApplicationQuit" event also will be fired.Some plugins used "OnApplicationQuit" event to release some resources. When onApplicationQuit has been fired but the game doesn't exit. I prevent it. During the game exiting some plugins work on error status.How I should do and avoid this problem?
Answer by dscolaro · Jul 03, 2020 at 05:38 PM
I am seeing the same behavior and I have filed a bug report on it (Case 1260583). It seems (to me) like calling OnApplicationQuit before the wantsToQuit handlers is the exact opposite of the desired behavior.
Bug added to Unity issue tracker
https://issuetracker.unity3d.com/product/unity/issues/guid/1261125
Your answer
![](https://koobas.hobune.stream/wayback/20220612231313im_/https://answers.unity.com/themes/thub/images/avi.jpg)