I have this Java script timer which works fine but I want to try and make one like this using the new U.I. system in C#?
This is the one I currently have in Java.
#pragma strict
private var time : float;
var textTime : String;
var timerOn : boolean;
var buttonText : String;
var beep1 : AudioClip;
var beep2 : AudioClip;
var buttonTexture: Texture2D;
function Start() {
timerOn = false;
buttonText = "Start";
}
function Update(){
if(timerOn)
time += Time.deltaTime;
}
function OnGUI () {
var guiTime = time;
var minutes : int = guiTime / 60; //Divide the guiTime by sixty to get the minutes.
var seconds : int = guiTime % 60;//Use the euclidean division for the seconds.
var fraction : int = (guiTime * 100) % 100;
textTime = String.Format ("{0:00}:{1:00}:{2:00}", minutes, seconds, fraction);
//text.Time is the time that will be displayed.
GetComponent(GUIText).text = textTime;
}
public function TimerOnOff()
{
// do your timer on/off stuff
timerOn = !timerOn;
if(timerOn) buttonText = "Stop";
else buttonText = "Start";
audio.PlayOneShot(beep1);
}
public function TimerReset()
{
// do your timer reset stuff
time = 0;
audio.PlayOneShot(beep2);
}