Today, I wrote a small watch, but it was actually very simple. I used it in ouarla.
First, create the clock, minute, second, and four points (, and ~~ Not that much.
The clock, minute, and second are the three parent-level centers. We need to note that we rotate the parent-level orah.
(Child-level vertices in the parent-level center)
Next we will write the code as follows:
Using unityengine; using system. collections; public class clock: monobehaviour {public transform Shi; Public transform fen; Public transform Miao; // use this for initializationvoid start () {}// update is called once per framevoid Update () {debug. log ("Hour" + system. datetime. now. hour); debug. log ("Minute" + system. datetime. now. minute); debug. log ("seconds" + system. datetime. now. second); // float miaonum = system. datetime. now. second * 6f; Miao. eulerangles = new vector3 (Miao. position. x, Miao. position. y,-miaonum); // minute float fennum = system. datetime. now. minute * 6f; fen. eulerangles = new vector3 (fen. position. x, Fen. position. y,-fennum); // hourly float shinum = system. datetime. now. hour * 6f; Shi. eulerangles = new vector3 (Shi. position. x, Shi. position. y,-shinum );}}
All values need to be * 6, because a total of 60 seconds, a circle is 360 degrees, and 1 second is 6 degrees.
It's easy to write.
Don't laugh...
:
[Unity3d self-learning Record] unity3d self-made watch