Applying an animation in the Spine Runtimes changes the state of the skeleton. In older versions of Spine, a previous animation may have left the skeleton in a weird state, wrecking subsequent animations. This led to adding lots of keys on frame 0 and as I mentioned, lots of keys isn't good!
I don't remember off the top of my head in what version we changed this, but in 3.8+ when using AnimationState if you have been applying an animation and that animation will no longer be applied, then it resets all the state that the animation changed back to the setup pose. This ensures that subsequent animations are applied on top of a known state. You no longer need to key everything on frame 0.
stikkanimate a écritI can confirm a time that you do need to close it off is when using changing colors with the 'Tint Black' option on slots within Unity. Otherwise, once it does a full loop on an animation, any slot using the Tint Black will turn black
This starts to get tricky because there are many ways to apply an animation.
When an animation is applied, all state that the animation changes (eg slot color) is set by the animation, though there are some slight differences when there is no key on frame 0:
If your animation is on the lowest track (or is the lowest track that keys that slot's color), then before the first key you get the setup pose color.
If your looping animation was on a higher track (ie a lower track keys that slot's color), then you'll get the slot color from the previous loop until the first key on the higher track. If you don't want this, you'd set a key on frame 0. Note that either way you don't need a key on the last frame.
stikkanimate a écritAlso, the Animation CleanUp export seems to erase color keys on the beginning and end so you have to use the manual animation cleanup first, then lay down a row of keys before exporting with Animation Cleanup off.
There are numerous rules, but animation clean up is safe to use in all cases when the animation will be applied on the lowest track. It will delete slot color keys at the start/end if they are the same as the setup pose's slot color.
If your animation is intended for use on a higher track, then animation clean up may delete keys that you need to prevent the lower track from showing. In that case unfortunately you don't want to use animation clean up. We don't yet have a way to mark keys as "protected" so animation clean up won't delete them. We plan to add that in v4.1.