unity3d - Display precise time remaining -
i have next code , want add together miliseconds var display this:
minutes : seconds : miliseconds
2 : 35 : 98
time.time time elapsed app begin, update function gets called every frame.
var starttime:float; var timeremaining:float; var minutes:int; var seconds:int; var miliseconds:int; var timestr:string; function start () { starttime = 130.0; } function update () { timeremaining = starttime - time.time; minutes = timeremaining / 60; seconds = timeremaining % 60; //miliseconds = ? timestr = minutes.tostring()+":"+seconds.tostring("d2"); guitext.text = timestr; }
if understand correctly trying do, seek code:
var starttime:float; var timeremaining:float; var minutes:int; var seconds:int; var miliseconds:int; var timestr:string; function start () { starttime = 130.0; } function update () { timeremaining = starttime - time.time; minutes = timeremaining / 60; seconds = timeremaining; miliseconds = timeremaining * 1000; seconds -= minutes*60; miliseconds -= seconds*1000; timestr = minutes.tostring()+":"+seconds.tostring("d2")+":"+miliseconds.tostring(); guitext.text = timestr; }
unity3d countdowntimer unityscript
No comments:
Post a Comment