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.
CrowdControl/Assets/3rd/StompyRobot/SRDebugger/Scripts/UI/Other/LoadingSpinnerBehaviour.cs

36 lines
869 B
C#

3 months ago
namespace SRDebugger.UI.Other
{
using SRF;
using UnityEngine;
public class LoadingSpinnerBehaviour : SRMonoBehaviour
{
private float _dt;
public int FrameCount = 12;
public float SpinDuration = 0.8f;
private void Update()
{
_dt += Time.unscaledDeltaTime;
var localRotation = CachedTransform.localRotation.eulerAngles;
var r = localRotation.z;
var fTime = SpinDuration/FrameCount;
var hasChanged = false;
while (_dt > fTime)
{
r -= 360f/FrameCount;
_dt -= fTime;
hasChanged = true;
}
if (hasChanged)
{
CachedTransform.localRotation = Quaternion.Euler(localRotation.x, localRotation.y, r);
}
}
}
}