You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Driftology/Assets/LoadingSpinner.cs

31 lines
739 B
C#

using UnityEngine;
using DG.Tweening;
public class LoadingSpinner : MonoBehaviour
{
[SerializeField] private float rotationSpeed = 90f; // Degrees per second
private Tween rotateTween;
private void OnEnable()
{
// Start rotation when enabled
rotateTween = transform.DORotate(
new Vector3(0, 0, -360),
1f / (rotationSpeed / 360f),
RotateMode.FastBeyond360
)
.SetEase(Ease.Linear)
.SetLoops(-1, LoopType.Restart);
}
private void OnDisable()
{
// Kill the tween when disabled
if (rotateTween != null && rotateTween.IsActive())
{
rotateTween.Kill();
rotateTween = null;
}
}
}