using UnityEngine;
using System.Collections;
using System;
public class ClockAnimater : MonoBehaviour {
private const float
hoursTogerees = 360f / 12f ,
minutesTogerees = 360f / 60f ,
secondsTogerees = 360f / 60f ;
public Transform hours, minutes, seconds ;
public bool analog ;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(analog){
TimeSpan timeSpan = DateTime.Now.TimeOfDay;
hours.localRotation = Quaternion.Euler(0f, 0f, (float)timeSpan.TotalHours * (- hoursTogerees));
minutes.localRotation = Quaternion.Euler(0f, 0f, (float)timeSpan.TotalMinutes * (- minutesTogerees));
seconds.localRotation = Quaternion.Euler(0f, 0f, (float)timeSpan.TotalSeconds * (- secondsTogerees));
}else{
DateTime time = DateTime.Now;
hours.localRotation = Quaternion.Euler (0f, 0f, time.Hour * ( hoursTogerees));
minutes.localRotation = Quaternion.Euler (0f, 0f, time.Minute * ( minutesTogerees));
seconds.localRotation = Quaternion.Euler (0f, 0f, time.Second * ( secondsTogerees));
}
}
void OnGUI()
{
GUILayout.Label((DateTime.Now.ToString()));
}
}
using System.Collections;
using System;
public class ClockAnimater : MonoBehaviour {
private const float
hoursTogerees = 360f / 12f ,
minutesTogerees = 360f / 60f ,
secondsTogerees = 360f / 60f ;
public Transform hours, minutes, seconds ;
public bool analog ;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(analog){
TimeSpan timeSpan = DateTime.Now.TimeOfDay;
hours.localRotation = Quaternion.Euler(0f, 0f, (float)timeSpan.TotalHours * (- hoursTogerees));
minutes.localRotation = Quaternion.Euler(0f, 0f, (float)timeSpan.TotalMinutes * (- minutesTogerees));
seconds.localRotation = Quaternion.Euler(0f, 0f, (float)timeSpan.TotalSeconds * (- secondsTogerees));
}else{
DateTime time = DateTime.Now;
hours.localRotation = Quaternion.Euler (0f, 0f, time.Hour * ( hoursTogerees));
minutes.localRotation = Quaternion.Euler (0f, 0f, time.Minute * ( minutesTogerees));
seconds.localRotation = Quaternion.Euler (0f, 0f, time.Second * ( secondsTogerees));
}
}
void OnGUI()
{
GUILayout.Label((DateTime.Now.ToString()));
}
}