I have this countdown script which works fine, there is just the problem, that the countdown restarts every time a new scene is loaded (which it should not). Is there a way to prevent it from doing that, and just let the countdown keep going even if a new scene is loaded?
Here is my code.
static var energyObj : int = 5;
var counter : float;
function Start()
{
counter = 1800;
}
function Update () {
counter -= Time.deltaTime;
if(counter <= 0){
energyObj += 1;
counter = 1800;
Debug.Log("Energy is " + energyObj);
}
}
function OnGUI () {
var minutes = Mathf.Floor(counter / 60).ToString("00");
var seconds = (counter % 60).ToString("00");
GUI.Label(new Rect(100,40,400,40),"To Next: " + minutes + ":" + seconds);
}