Time.realTimeSinceStartup in Unity
Notes:
Time.realtimeSinceStartup in Unity
- returns the real time passed in seconds; since the game started
Time.realtimeSinceStartup = Total game play time + Total game pause time
Note: is not affected by Time.timeScale
i.e. even if the game is paused behind the scene it keeps on updating and does not scale or descale according to Time.timeScale value.
Application:
If you want to perform some actions with respect to time even if the game is paused use Time.realtimeSinceStartup.
Example Code:
void Start ()
{
Debug.Log ((int)Time.realtimeSinceStartup);
}
void Update ()
{
Debug.Log ((int)Time.realtimeSinceStartup);
}
void OnApplicationQuit()
{
Debug.Log ((int)Time.realtimeSinceStartup);
}