[unity] Fixed animations not mixing out on some Update When Invisible modes, leaving e.g. leftover slots. Closes #2873.

This commit is contained in:
Harald Csaszar 2025-06-27 15:51:37 +02:00
parent 7247873cf9
commit 636d65d72a

View File

@ -191,6 +191,7 @@ namespace Spine.Unity {
if (!valid)
return;
state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
state.Dispose += OnAnimationDisposed;
wasUpdatedAfterInit = false;
if (!string.IsNullOrEmpty(_animationName)) {
@ -302,6 +303,14 @@ namespace Spine.Unity {
if (previousUpdateMode != UpdateMode.FullUpdate)
LateUpdate();
}
protected virtual void OnAnimationDisposed (TrackEntry entry) {
// when updateMode disables applying animations, still ensure animations are mixed out
if (updateMode != UpdateMode.FullUpdate &&
updateMode != UpdateMode.EverythingExceptMesh) {
entry.Animation.Apply(skeleton, 0, 0, false, null, 0f, MixBlend.Setup, MixDirection.Out);
}
}
}
}