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; } } }