powerfun-unity/Assets/RotationRectLoop.cs

32 lines
767 B
C#
Raw Normal View History

2022-04-29 19:03:18 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
[RequireComponent(typeof(RectTransform))]
public class RotationRectLoop : MonoBehaviour
{
RectTransform rect { get; set; }
Vector3 startvalue;
Vector3 endvalue;
// Start is called before the first frame update
void Start()
{
rect = GetComponent<RectTransform>();
endvalue = new Vector3(0, 0, 180);
startvalue = new Vector3(0, 0, 360);
}
float timer = 0f;
float angle = -15;
// Update is called once per frame
void Update()
{
timer -= Time.deltaTime;
while (timer < 0)
{
rect.Rotate(new Vector3(0, 0, 1), angle);
timer += 0.1f;
}
}
}