Clock Script

Hello,

i have found this Script:

using UnityEngine;
using System;

public class ClockAnimator : MonoBehaviour {

private const float
hoursToDegrees = 360f / 12f,
minutesToDegrees = 360f / 60f,
secondsToDegrees = 360f / 60f;

public Transform hours, minutes, seconds;
public bool analog;

void Update() {
if (analog) {
TimeSpan timespan = DateTime.Now.TimeOfDay;
hours.localRotation =
Quaternion.Euler(0f,0f,(float)timespan.TotalHours * -hoursToDegrees);
minutes.localRotation =
Quaternion.Euler(0f,0f,(float)timespan.TotalMinutes * -minutesToDegrees);
seconds.localRotation =
Quaternion.Euler(0f,0f,(float)timespan.TotalSeconds * -secondsToDegrees);
}
else {
DateTime time = DateTime.Now;
hours.localRotation = Quaternion.Euler(0f, 0f, time.Hour * -hoursToDegrees);
minutes.localRotation = Quaternion.Euler(0f, 0f, time.Minute * -minutesToDegrees);
seconds.localRotation = Quaternion.Euler(0f, 0f, time.Second * -secondsToDegrees);
}
}
}

Can someone please ADD the Function that he would on every HOUR play a Sound?
Thanks in Advance!
Greetings,
halobungie

Just check minutes and seconds:


DateTime time = DateTime.Now;
hours.localRotation = Quaternion.Euler(0f, 0f, time.Hour * -hoursToDegrees);
minutes.localRotation = Quaternion.Euler(0f, 0f, time.Minute * -minutesToDegrees);
seconds.localRotation = Quaternion.Euler(0f, 0f, time.Second * -secondsToDegrees);
}

if(DateTime.Now.Minute == 0 DateTime.Now.Second == 0)
{
PlaySound();
}

}
private void PlaySound()
{
/// TODO: call Play() method of your AudioClip
}

}