So let say you want to create a time tracker to track seconds, minutes, hours, so below is how you do it
var timer1 : double;
var seconds: int;
var minutes: int;
var hours: int;
var niceTime: String;
function Update()
{
timer1 += Time.deltaTime;
}
function OnGUI ()
{
hours= Mathf.FloorToInt(timer1 / 3600F);
minutes = Mathf.FloorToInt(timer1 / 60F);
seconds = Mathf.FloorToInt(timer1 - minutes * 60);
niceTime = String.Format("{0:00}:{1:00}:{2:00}", hours,minutes, seconds);
GUI.Label (Rect (200, 150, 120, 40), niceTime );
}
No comments:
Post a Comment