Tuesday, September 23, 2014

Unity how to track and display hour minute seconds

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 secondsint;
var minutesint;

var hoursint;
var niceTimeString;


function Update()
{
   
        timer1 += Time.deltaTime;
    
 } 


function OnGUI ()
{

            hoursMathf.FloorToInt(timer1 / 3600F);
            minutes = Mathf.FloorToInt(timer1 / 60F);
            seconds = Mathf.FloorToInt(timer1 - minutes * 60);
 
            
niceTime = String.Format("{0:00}:{1:00}:{2:00}"hours,minutesseconds);
            

 
  
        
        GUI.Label (Rect (20015012040), niceTime );



}

No comments:

Post a Comment