PowenKo, Unity3d Tutorial 149,Timer, timer in the game

October 30, 2011   ·   0 Comments

private var startTime;
var textTime : String; //added this member variable here so we can access it through other scripts


function Awake() {

   startTime = Time.time;

}

function OnGUI () {

   var guiTime = Time.time - startTime;

   var minutes : int = guiTime / 60;
   var seconds : int = guiTime % 60;
   var fraction : int = (guiTime * 100) % 100;

   text = String.Format ("{0:00}:{1:00}:{2:000}", minutes, seconds, fraction); 
   GUI.Label (Rect (400, 25, 100, 30), textTime); //changed variable name to textTime -->text is not a good variable name since it has other use already

}
shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon