onApplicationPause and time

Hey all,

Trying to fix a little issue i’ve got when i pause. Here’s the code…

	void OnApplicationPause(bool pause)
	{
		float pauseTime = Time.time;
		float duration = 120.0f;
		if(pause)
		{
			pauseTime = Time.time;
			Debug.Log("We got the current time");
		}
		else
		{
			if(PlayerPrefs.GetInt("gameversion") == 0 || PlayerPrefs.GetInt("gameversion") == 2)
			{
				if(Time.time > (pauseTime + duration))
				{
					Debug.Log("Its has been more then an HOUR... ");
				}
				else
				{
					Debug.Log((pauseTime + duration) + " was when we paused and we are not at " + Time.time);
				}
			}
		}
			
	}

Problem i’m having is that pausedTime always = Time.time… and i need it to be the time when we paused and stay that way. Any thoughts on what i’m doing wrong there?

Thanks in advance
Bryan

@theinfomercial

Thanks! Thats the tip i needed… i guess it does make sense that unity doesn’t keep track of normal time when its paused.

Cheers
Bryan