my timer code:
#pragma strict
private var initialtime : float;
private var texttime : String;
var CountMinutes : int;
var CountSeconds : int;
private var restseconds : int;
private var minutes : int;
private var seconds : int;
var guitime : float;
function Start () {
initialtime=Time.time;
CountSeconds = CountSeconds + (CountMinutes*60);
}
function OnGUI () {
guitime = Time.time - initialtime;
restseconds = CountSeconds - guitime;
seconds = restseconds%60;
minutes = restseconds/60;
texttime = String.Format("{0}:{1}",minutes, seconds);
GetComponent(GUIText).text = texttime;
if(seconds <=0 && minutes <=0)
{
//Pause the game
Time.timeScale = 0;
DontDestroyOnLoad(GameObject.Find("Diamond"));
Application.LoadLevel("Score");
}
}
I have this script on another object that loads a new scene then in that scene there is a button that lets me go back to the timer scene again then when I am in the timer scene the timer just doesn’t move. I don’t get why. But theres this other button that loads another scene and if I return to the timer scene the timer would work fine. Does anyone have any ideas? Thanks