What's the best way to set a looping animation inside an update method without restarting the animation?
I have the following code but I'm afraid it might be inefficient.
void Update()
{
if (IsPlaying(0, animation)) return;
skeletonAnimation.AnimationState.SetAnimation(0, animation, true);
}
public bool IsPlaying(int trackIndex, string animationName)
{
var animation = skeletonAnimation.AnimationState.Data.SkeletonData.FindAnimation(animationName);
var trackEntry = skeletonAnimation.AnimationState.GetCurrent(trackIndex);
if (trackEntry == null) return false;
return trackEntry.Animation == animation;
}