NG_/Assets/Scripts/UI/动效/RotateImage.cs
2024-12-13 19:40:05 +08:00

25 lines
609 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 控制图片旋转的脚本
public class RotateImage : MonoBehaviour
{
public float rotationSpeed = -50f; // 旋转速度
void Update()
{
// 当前的旋转角度
float currentRotation = transform.eulerAngles.z;
// 累加旋转
currentRotation += rotationSpeed * Time.deltaTime;
// 保证旋转角度在 0 到 360 之间
currentRotation %= 360f;
// 应用新的旋转角度
transform.rotation = Quaternion.Euler(0f, 0f, currentRotation);
}
}