- 最后登录
- 2016-8-29
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 23585
- 纳金币
- 20645
- 精华
- 62
|
public Transform secondHandPivot;
public Transform minuteHandPivot;
public Transform hourHandPivot;
DateTime time = DateTime.Now;
float seconds = (float)time.Second;
float minutes = (float)time.Minute;
float hours12 = (float)time.Hour % 12;
float angleSeconds = -360 * (seconds / 60);
float angleMinutes = -360 * (minutes / 60);
float angleHours = -360 * (hours12 / 12);
secondHandPivot.localRotation=Quaternion.Euler(0f,0f,angleSeconds);
minuteHandPivot.localRotation=Quaternion.Euler(0f,0f,angleMinutes);
hourHandPivot.localRotation=Quaternion.Euler(0f,0f,angleHours);
注意:因为unity使用的是左手坐标系排列Z轴,旋转角度只能是负数,因此负的360乘以时间可以得到旋转的角度。
|
|