This repository has been archived on 2024-11-16. You can view files and clone it, but cannot push or open issues or pull requests.
2021-01-29 19:12:31 +08:00

27 lines
795 B
C#

using System;
using UnityEngine;
public class Clock : MonoBehaviour
{
const float hoursToDegrees = -30.0f;
const float minutesToDegrees = -6.0f;
const float secondsToDegrees = -6.0f;
[SerializeField]
Transform hoursPivot = default;
[SerializeField]
Transform minutesPivot = default;
[SerializeField]
Transform secondsPivot = default;
private void Update()
{
var time = DateTime.Now.TimeOfDay;
hoursPivot.localRotation = Quaternion.Euler(0.0f, 0.0f, hoursToDegrees * (float)time.TotalHours);
minutesPivot.localRotation = Quaternion.Euler(0.0f, 0.0f, minutesToDegrees * (float)time.TotalMinutes);
secondsPivot.localRotation = Quaternion.Euler(0.0f, 0.0f, secondsToDegrees * (float)time.TotalSeconds);
}
}