示例#1
0
    private void UpdateClock()
    {
        if (Time.time >= updateTimer)
        {
            updateTimer = Time.time + updateInterval;
            DateTime time = DateTime.Now;
            currentTime = time.ToLongTimeString();
            if (!audioHandler)
            {
                ClockInit();
            }
            if (audioHandler.GetFX())
            {
                audioSource.PlayOneShot(secondHandFX[Mathf.FloorToInt(URandom.Range(0, secondHandFX.Length))]);
            }

            if (!legacyMode)
            {
                secondHand.localRotation = Quaternion.Euler(0f, 0f, time.Second * semiNotch);
                minuteHand.localRotation = Quaternion.Euler(0f, 0f, (time.Minute * semiNotch) + (time.Second * rFac_Minute));
                hourHand.localRotation   = Quaternion.Euler(0f, 0f, (time.Hour * notch) + (time.Minute * rFac_Hour));
            }
            else
            {
                secondHand.localRotation = Quaternion.Euler(0f, time.Second * semiNotch, 0f);
                minuteHand.localRotation = Quaternion.Euler(0f, (time.Minute * semiNotch) + (time.Second * rFac_Minute), 0f);
                hourHand.localRotation   = Quaternion.Euler(0f, (time.Hour * notch) + (time.Minute * rFac_Hour), 0f);
            }
        }
    }