-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathClock.cs
More file actions
27 lines (23 loc) · 857 Bytes
/
Clock.cs
File metadata and controls
27 lines (23 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Pure.DI;
using UnityEngine;
public class Clock : MonoBehaviour
{
const float HoursToDegrees = -30f, MinutesToDegrees = -6f, SecondsToDegrees = -6f;
[SerializeField] Scope scope;
[SerializeField] Transform hoursPivot;
[SerializeField] Transform minutesPivot;
[SerializeField] Transform secondsPivot;
[Dependency]
public IClockService ClockService { private get; set; }
void Awake()
{
scope.BuildUp(this);
}
void Update()
{
var now = ClockService.Now.TimeOfDay;
hoursPivot.localRotation = Quaternion.Euler(0f, 0f, HoursToDegrees * (float)now.TotalHours);
minutesPivot.localRotation = Quaternion.Euler(0f, 0f, MinutesToDegrees * (float)now.TotalMinutes);
secondsPivot.localRotation = Quaternion.Euler(0f, 0f, SecondsToDegrees * (float)now.TotalSeconds);
}
}