Forum Discussion
max_desplanches
6 years agoHonored Guest
Unity OnApplicationQuit() call when closing app
Hi,
Regards
I need to send a message to a server when my oculus Quest app is closed.
In OnApplicationQuit(), I'm calling my function to send a message to the server but it appeared that the server never received the message.
Are all Unity's methods are called when closing an app on Oculus Quest ?
Is there a better way to send call a function when clicking on the close app button from Oculus menu ?
Is there a better way to send call a function when clicking on the close app button from Oculus menu ?
Regards
2 Replies
- Kev1970ExplorerI dont think onaplicationquit ever gets called.
Onapplicationpaused is called but not in all cases (like the user just taking the headset off, although perhaps after 10 seconds it may be, by which time they may have turned the device off).
You can check in update to see if the user is still wearing the headset and if theyre not then take action in case they end up quitting. Do the same for the pause state and you should be covered for all scenarios of users quitting your application.
Just honouring onapplicationquit would have been much easier and more intuitive of course. - rh_galaxyHeroic ExplorerI don't see the OnApplicationQuit call... I myself doesif (Menu.bQuit) //indication in my own code that we should quit
{
#if UNITY_EDITOR
//Application.Quit() does not work in the editor so
// this need to be set to false to end the game
UnityEditor.EditorApplication.isPlaying = false;
#else
UnityEngine.Application.Quit();
#endif
}
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago
- 9 months ago