lblast

Hello,

I'm having some issues using the AnimationState.Complete functionality.

Basically what I have is this:
vault.AnimationState.SetAnimation(0, STATE + VaultAnim.OpenIdle, false);

for (int i = prev; i < curr; i++)
{
vault.AnimationState.AddAnimation(0, STATE + i + VaultAnim.TransitionState + (i + 1), false, 0f);
}

vault.AnimationState.Complete += OnDoneTransitions;
The issue I'm having is OnDoneTransitions fires right after my OpenIdle animation, it doesn't wait until the TransitionStates are complete. How do I wait until all my animations are done?
lblast
  • Posts: 2

Misaki

The AnimationState.Complete event will be emitted for all queued animations on all tracks, so you should register to a TrackEntry.Complete event. The following is a quote from the documentation:
The skeleton animation component provides delegates to which C# code can bind in order to react to these events for all queued animations on all tracks. Listeners can also be bound to the corresponding delegates of a specific TrackEntry only. So you can register to e.g. AnimationState.Complete to handle event callbacks for any future animation Complete event, or instead register to a single TrackEntry.Complete event to handle Complete events issued by a single specific enqueued animation.
spine-unity Runtime Documentation: Processing AnimationState Events

Therefore, I think registering OnDoneTransitions to the TrackEntry of the last transition animation and listening to the Complete event for it should work.
User avatar
Misaki

Misaki
  • Posts: 1164

lblast

I believe I understand. Okay thanks I will try that!
lblast
  • Posts: 2


Return to Unity