Last time I wrote a blog about the timekeeping function.
Today this article and the last article to achieve the same idea, the result is the same
Previous post address: http://www.cnblogs.com/shenggege/p/4251123.html
The idea decides everything ...
This idea is much better than the last time, thank you for my good friends of the whole guidance
The idea is to new a time, month and day to write casually, time/minute/second/millisecond zeroing
Why go to zero?
Because every time we execute it in the update, we +time.deltatime the second
Then remove the minute/second/millisecond separately
Limited ability to express, for instance.
2015.1.30.17.17.41.33
No previous month day: 17:17 41 seconds 33 milliseconds
Each time the update is executed, we add the times and then take the minute/second/millisecond separately
At the end of the string, we get the results we want.
Alas, the explanation is not perfect, this is the limit of my ability to express language.
I'll go directly to the code, the code is small.
1 PrivateDateTime TimeNow =NewDateTime (1994,Ten, +,xx,xx,xx,xx);2 3 voidUpdate ()4 {5TimeNow =timenow.addseconds (time.deltatime);6 7 Setgametime (TimeNow, time);8 Setgametime (TimeNow, best);9 Ten //This is for the time of comparison. One //Debug.Log (Datetime.compare (DateTime.Now, TimeNow)); A } - - ///Play Time<summary> the ///Play Time - /// </summary> - /// <param name= "_time" >Time</param> - /// <param name= "TimeType" >Time Type</param> + Private voidSetgametime (DateTime _time, uisprite[] timetype) - { + //Stitching characters A //final format: 001122 at stringCurrentTime =string. Format ("{0}{1}{2}", - //pick up and fill 0 -_time. Minute.tostring (). PadLeft (2,'0'), - //take seconds to fill 0 -_time. Second.tostring (). PadLeft (2,'0'), - //take milliseconds/10 to 0 (1s=1000ms only requires two digits so/10) in(_time.millisecond/Ten). ToString (). PadLeft (2,'0') - ); to + //show the corresponding graph (I'm using calligraphy instruction) - for(inti =0; I <6; i++) theTimetype[i].spritename = currenttime.substring (i,1); *}
The above is all the code, we hope to help!
Now look back at the last article on this feature, not looking straight
Oh oh, almost forgot!!
Using this idea, when divided into 60 ticks, will automatically reset to zero
Because 60 points = 1 o'clock! That is, when divided into 60 o'clock, there will be bug!
It's zero! Maggie's Zero! Zeroing in! It's zero! Out!!
But then again which two goods will hang on the phone for 60 minutes just to wait for this bug to appear ...
This article link: http://www.cnblogs.com/shenggege/p/4262905.html
Unity3d Chronograph function Solution