Hi there, I have some code like this:

skeletonAnimation.AnimationState.SetAnimation(0, "A", false).Complete += delegate
{
skeletonAnimation.AnimationState.SetAnimation(0, "B", false);
andSomethingElse();
};
if (somethingHappend) skeletonAnimation.AnimationState.SetAnimation(0, "C", false);

The problem is when 'somethingHappend' happens in some specific timing, spine will play animation "C" for a little time then immediately change to "B".
I know I can remove event by using '-=', but I wonder is there a way to clear ALL events so I don't need to make delegate to a 'official' method.
I did see a method called 'TrackEntry.Reset' which can clear all events, but I'm afraid it might cause other problems.
Or did I do something wrong from the beginning?

    Related Discussions
    ...

    KarenArushi If you want to play "C" to the end and then "B", why not queue "B" to the track 0 by AddAnimation()? Sorry if I misunderstood your issue.

      Misaki Thanks for replay.
      What I want is play "A" to the end and then "B". but if something happend(like character getting attack) during play, stop "A" or "B" and turn to "C".
      I didn't notice there are AddAnimation method, I guess it will solve my problem.
      But I still wonder is there a way to clear all events? this bothers me for a long time.

      @KarenArushi I'm afraid there are no exposed clear methods for TrackEntry events which would set the event to null like TrackEntry.Reset(), which however clears all TrackEntry properties, being similar to a destructor. So Reset() is not what you want. You could modify the source code of AnimationState.cs accordingly and add methods to TrackEntry like ClearComplete() or similar which sets Complete = null, if you really want to do that.

      If you can describe a use case which justifies that we add such clear methods, we might consider doing just that. Normally you would however just want to unregister youself from receiving events. Unfotunately, delegates in C#, while being quite flexible, make this a bit more labour-intensive. You could e.g. keep a list of all registered delegates in order to unregister all at once if you would otherwise call something like removeListener(this).

        KarenArushi The problem is when 'somethingHappend' happens in some specific timing, spine will play animation "C" for a little time then immediately change to "B".

        I don't understand what you mean. If SetAnimation(C) is called after setting A and B, then C will played. It won't play C for a little while, then play B.

        If you have a mix duration, it may be that while C is playing A and/or B continue to be applied while they are mixed out. In that case you may receive events like Complete for A or B. You can check if the current track entry is not A or B and ignore those events.

          Nate Thank you, I believe that's exactly what happening on me.

          Harald Thank you very much, that is very detiled, I'll give it a try.