How to make reset function of the script with Count Up time like this :
#pragma strict
private var restSeconds : float;
private var roundedRestSeconds : int ;
private var displaySeconds : float;
private var displayMinutes : float;
private var Timeleft : float ;
var timetext : String;
private var countUp = true;
function Start()
{
countUp = true;
}
function Update()
{
if(restSeconds == 500)
{
resetTime();
}
}
function OnGUI()
{
GUI.Label( Rect(MarginLeft,MarginTop,MarginLeft + Width,MarginTop + Height), timetext);
if(countUp == true)
{
Timeleft= Time.time+Time.deltaTime;
restSeconds = CountUpSeconds+(Timeleft);
roundedRestSeconds=Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = (roundedRestSeconds / 60)%60;
timetext = (displayMinutes.ToString()+":");
if (displaySeconds > 9)
{
timetext = timetext + displaySeconds.ToString();
}
else
{
timetext = timetext + "0" + displaySeconds.ToString();
}
}
}
function resetTime()
{
}
I Have tried some trick like restSeconds = 0 or Timeleft = 0 it’s still continuing previous time, even I implemented Application.LoadLevel ("Current Level"); . Any suggestions ?