- Home /
OnApplicationQuit called outside the game
I'm creating a game that needs to send a web request to the server right before the game is closed. I need this information when he logs back into the game afterwards. I'm using OnApplicationQuit() and it works great testing inside Unity, everytime I click the play button to stop the game it is called and I'm able to send the request to the server before it closes the game.
My question is: is OnApplicationQuit() called when I build the game and force close it on android by swipping the app up and down? If not, how do you guys work this out?
Thank you!
Answer by Casiell · Jan 21, 2021 at 08:11 AM
On android I always used OnApplicationFocus. I always assume that if the game is in the background, I have little to no control over it, and mobile devices have so many ways of killing the application that one of them is bound to fail to tell me about it. This way I send some unnecessary web requests, but it shouldn't be that many and IMO better safe than sorry
Your answer
Follow this Question
Related Questions
how do I fixate a position through script. 1 Answer
Making a gameobject inactive and locating a clone. What's wrong with the script? 1 Answer
How do i give Coordinates (x, y) to an Array 1 Answer
Ways to make OnMouseDown (or a single script) differentiate between different colliders/sprites 1 Answer
c# - List with multiple types - Trading Engine - Stock Simulator 2 Answers