OnApplicationQuit() Function in Unity
Notes:
OnApplicationQuit() Function in Unity:
7. When user quits application or stops play mode in Unity Editor
OnApplicationQuit method:
- is called when user quits the game application
- is called when user stops play mode in the Unity Editor.
Note: When user quits the game application first it loses focus and then quits.
- is best for saving / persisting any game data
Ex: Saving how much time user has played the game
Example code:
void OnApplicationQuit()
{
Debug.Log ("OnApplicationQuit");
Debug.Log (Time.time);
}
Note: Time.time returns total time since the start of game