Hello everyone!
I’m made a simple runtime timer for my camera. Now I’m trying to save the time, but it doesn’t save…
Can someone give me some advice on what am I doing wrong here?
Any tip / advice is highly appreciated! Thank you very much!
P.S. Sorry if my english is bad.
#pragma strict
static var timer : float;
var timer_text : GameObject;
private var check : boolean = false;
function Awake ()
{
timer = PlayerPrefs.GetFloat("RecordingTime_timer");
}
function Update ()
{
if(!check)
{
var t : System.TimeSpan = System.TimeSpan.FromSeconds(timer);
timer_text.guiText.text = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", t.Hours, t.Minutes, t.Seconds, t.Milliseconds);
timer += Time.deltaTime;
if(timer > PlayerPrefs.GetFloat("RecordingTime_timer"))
PlayerPrefs.SetFloat("RecordingTime_timer", timer);
wait();
}
}
function wait ()
{
check = true;
yield WaitForSeconds(0.3);
check = false;
}