• Bugs
  • Spine export clean up

Related Discussions
...

Spine version 3.8.99
Unity version 2018.4.30f1
There are two spine animation in TestSpineScene.scene, one used "animation clean up" when export from spine, another without.
Both of them play "idle" animation, and then play "appear" animation.

Thanks for reporting. Please note that Animation cleanup will remove keys that are identical to the setup pose. This is not always what you want, so in many cases you will need to disable Animation cleanup.

Animation clean up should always be safe to use on the lowest AnimationState track. If using an animation on a higher track, clean up may delete keys you need.

We'll take a look at your files and get back to you soon!

Thanks, it looks like remove keys that are identical to the setup pose.
I find this in guide:
"In the future Spine will allow marking keys as "protected" so Clean Up will not remove them."
In my opinion, most of users need "protected" and "don't clear first key" when they choose Clean Up.

Yep, that feature will help!

You shouldn't need any key protection when using clean up when your animation will be used on the lowest track. If clean up causes a problem for the lowest track, we'd like to see the project file (before clean up).

my code like:
m_SkeletonAnimation.AnimationState.ClearTracks();
m_SkeletonAnimation.AnimationState.Update(0);

    m_SkeletonAnimation.AnimationState.SetAnimation(0, appearAnim, false); // invoke spine animation

track index equal 0.

Spine project file in spine.zip without clean up. I only use it in export.

If you only set an animation on a single track number (zero in your code above) then animation clean up should not wreck your animations. Can you please send us the project file (we don't need the images) and tell us the name of the animation that has the problem? contact@esotericsoftware.com

I can't understand.
I have upload two file in the first time.
spine.zip contains:
area101_center_decor_2.spine // spine project, 3.8.99
Animation/* // export without clean up
AnimationCleanUp/* // export and clean up

TestSpine.zip contains unity project
Play TestSpineScene.scene can trigger this problem.
Did I miss anything?

I'm very sorry! I missed your attachments in the first post. I tried the exports in the "Animation" and "AnimationCleanUp" folders with the 3.8.99 Skeleton Viewer and the animations render exactly the same.

Looking at your code, the problem is this line:

m_SkeletonAnimation.AnimationState.ClearTracks();

See TrackEntry clearTracks:

Removes all animations from all tracks, leaving skeletons in their current pose.

You are playing the idle animation, then clearing all tracks, leaving the skeleton in the idle animation pose. You then play the appear animation, which will only pose the skeleton for the timelines it has. appear doesn't key all the same timelines that idle does, so some of the skeleton pose is left in the idle pose.

The problem is as Harald said: when you use animation clean up, it removes keys for the setup pose. Normally this is not a problem, but you have left the skeleton in the idle pose by using ClearTracks.

You could use SetToSetupPose after ClearTracks. However, there is no reason to call ClearTracks at all. You can just call SetAnimation to play appear. AnimationState handles resetting everything back to the setup pose when an animation (idle in this case) will no longer be applied.

Thanks! I have used "ClearTracks" to force delete animation mix. It's my fault.

No worries, it's good to understand why it does what it does. You can set the mix duration:

TrackEntry entry = m_SkeletonAnimation.AnimationState.SetAnimation(0, appearAnim, false);
entry.MixDuration = 0;