OnApplicationPause() Function in Unity

Notes:

OnApplicationPause() Function in Unity:

3. Game Application comes to foreground

OnApplicationPause method:
- is called after OnEnable, if script is enabled
- is called after Awake, if script is not enabled
- is also called whenever game application goes to background and comes to foreground

- Whenever a game application comes to foreground it receives False value, which indicates game is currently running.
- Whenever a game application goes to background it receives True value, which indicates game is currently paused.

- is best to check whether game application is currently running or paused

Example Code:

void OnApplicationPause(bool isApplicationPause)
{
Debug.Log ("isApplicationPause " + isApplicationPause);
}