There is no parameter like a "default idle" animation available in the Spine API. The last frame of a non-looping animation will be held until it is mixed out via e.g. SetEmptyAnimation()
. However, there are many ways to achive what you want.
You could call AnimationState.AddAnimation()
with your default (e.g. idle
) animation after setting e.g. an attack animation.
skeletonAnimation.AnimationState.SetAnimation(0, attackAnim, true);
skeletonAnimation.AnimationState.AddAnimation(0, idleAnim, true);
This enqueues your animation after the previous animation has finished. This would be the simplest way. You may also want to call AnimationState.AddEmptyAnimation()
when on higher tracks to mix out an animation after it has completed.
Another way would be to register to the AnimationState.Complete
event and react to it when it is not a looping animation:
void Start() {
...
skeletonAnimation.AnimationState.Complete += OnComplete;
}
void OnComplete (TrackEntry trackEntry) {
if (!trackEntry.Loop && trackEntry.Next == null)
skeletonGraphic.AnimationState.SetAnimation(0, idleAnim, true);
}
For more info on events see the documentation pages here:
http://esotericsoftware.com/spine-unity#Processing-AnimationState-Events
http://esotericsoftware.com/spine-api-reference#AnimationStateListener-complete