首页 > 其他分享 >CatLikeCoding Basic No.1

CatLikeCoding Basic No.1

时间:2023-01-18 22:00:11浏览次数:45  
标签:CatLikeCoding localRotation float Quaternion 0f time No.1 Basic using

 

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class clock : MonoBehaviour
{
    const float hoursToDegrees = -30f, MinToDegrees = -6f, SecToDegrees = -6f;
    [SerializeField]
    Transform hourPivot, minutesPivot, secondsPivot;
    // Start is called before the first frame update
    void Start()
    {
         
    }

    // Update is called once per frame
    void Update()
    {
        TimeSpan time = DateTime.Now.TimeOfDay;
        hourPivot.localRotation =
            Quaternion.Euler(0f, 0f, hoursToDegrees * (float)time.TotalHours);
        minutesPivot.localRotation =
            Quaternion.Euler(0f, 0f, MinToDegrees * (float)time.TotalMinutes);
        secondsPivot.localRotation =
            Quaternion.Euler(0f, 0f, SecToDegrees * (float)time.TotalSeconds);
    }
}

 

标签:CatLikeCoding,localRotation,float,Quaternion,0f,time,No.1,Basic,using
From: https://www.cnblogs.com/lofu/p/17060698.html

相关文章