cancel
Showing results for 
Search instead for 
Did you mean: 

Unity OnApplicationQuit() call when closing app

max_desplanches
Honored Guest
Hi,

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 ?

Regards
2 REPLIES 2

Kev1970
Explorer
I 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_galaxy
Heroic Explorer
I don't see the OnApplicationQuit call... I myself does

if (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
}