Hey everyone,
I’m trying to output the length of time the game ran as the players score on the ‘game-over’ screen.
so far I have the code
void OnGUI()
{
GUI.Label(new Rect(10, 10, 150, 30), "Seconds Alive: " + (int)(Time.fixedTime)); // Multiply playerScore by whatever you want to make for (seconds played * x)
}
This code works during the game, outputting the seconds the player has been alive.
for the exist screen I have…
void OnGUI()
{
GUI.Label(new Rect(Screen.width / 2 - 40, 50, 80, 30), "YOU DIED");
GUI.Label(new Rect(Screen.width / 2 - 40, 300, 80, 30), "You survived for : " + Time.fixedTime);
if (GUI.Button(new Rect(Screen.width / 2 -30, 350, 60, 30), "Retry?"))
{
Application.LoadLevel(0);
}
}
However it just counts up the time the current screen has been loaded.
Anybody have any ideas?