Pausing a Time counter/Reseting

I Have a Gui in my game that keeps track of the amount of time the player stays alive (Kind of Like their score). When the player dies I want the Time to be paused so the Game Over screen will have that number displayed. Then when they Restart the game, the time must be reset.

    `void Update ()
{
	timeText.text = "" + Time.time;

	if (gameOver) {
		timeText.text = "" + Time.realtimeSinceStartup;
			}

	if(restart)
	{
		if (Input.GetKeyDown (KeyCode.R))
		{
			Application.LoadLevel (Application.loadedLevel);
		}
	}`

if (gameOver) {
timeText.text = “” + Time.realtimeSinceStartup;
}

This snippet of code did not work how I wanted it to :confused:

You can do it this way:

private float myTime = 0.0f;

void Update () {

    timeText.text = myTime.ToString();
 
    if (!gameOver) {
        myTime += Time.deltaTime;
     }
 
    if (restart) {
       if (Input.GetKeyDown (KeyCode.R)) {
         Application.LoadLevel (Application.loadedLevel);
       }
    }
}

Once ‘gameOver’ becomes true, then myTime is no longer incremented.