I just use a generic code to count how long the player has been playing in the update function:
float time;
void Update()
{
time += Time.unscaledDeltaTime;
}
Here is the problem:
When I press the home button on my android device or browse past applications the timer still counts. So if I wait a while in home or in other apps screen and come back to the game, the timer includes time even when I have been out of the app. The game state stays exactly how it was before but only the timer changes.
What could be the reason and how can I prevent the timer from counting when the application does not have focus?