rise-and-swine/Assets/Scripts/Assembly-CSharp/AnimationLoop.cs

45 lines
867 B
C#
Raw Normal View History

2023-02-25 23:04:03 -05:00
using Spine.Unity;
using UnityEngine;
public class AnimationLoop : MonoBehaviour
{
private void Start()
{
this.skeletonAnimation.state.SetAnimation(0, this.animationName, false);
this.skeletonAnimation.state.End += this.OnAnimationEnd;
this.animationPlaying = true;
}
private void Update()
{
if (this.animationPlaying)
{
return;
}
this.counter -= Time.deltaTime;
if (this.counter <= 0f)
{
this.skeletonAnimation.state.SetAnimation(0, this.animationName, false);
}
}
private void OnAnimationEnd(Spine.AnimationState state, int trackIndex)
{
this.counter = this.interval;
this.animationPlaying = false;
}
[SerializeField]
private SkeletonAnimation skeletonAnimation;
[SerializeField]
private float interval;
[SerializeField]
private string animationName;
private bool animationPlaying;
private float counter;
}