From 08a29352ef59107245b19ecf7394fd3600e3847e Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 9 Dec 2024 18:15:09 +0100 Subject: [PATCH] [csharp] Port of commit 8d058fb: Improved AnimationState behavior when paused. See #2705. --- spine-csharp/src/AnimationState.cs | 20 +++++++++++--------- spine-csharp/src/package.json | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 06cdc7f39..c2ba7bc66 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -204,16 +204,18 @@ private bool UpdateMixingFrom (TrackEntry to, float delta) { from.animationLast = from.nextAnimationLast; from.trackLast = from.nextTrackLast; - // Require mixTime > 0 to ensure the mixing from entry was applied at least once. - if (to.mixTime > 0 && to.mixTime >= to.mixDuration) { - // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). - if (from.totalAlpha == 0 || to.mixDuration == 0) { - to.mixingFrom = from.mixingFrom; - if (from.mixingFrom != null) from.mixingFrom.mixingTo = to; - to.interruptAlpha = from.interruptAlpha; - queue.End(from); + if (to.nextTrackLast != -1) { // The from entry was applied at least once. + bool discard = to.mixTime == 0 && from.mixTime == 0; // Discard the from entry when neither have advanced yet. + if (to.mixTime >= to.mixDuration || discard) { + // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded. + if (from.totalAlpha == 0 || to.mixDuration == 0 || discard) { + to.mixingFrom = from.mixingFrom; + if (from.mixingFrom != null) from.mixingFrom.mixingTo = to; + to.interruptAlpha = from.interruptAlpha; + queue.End(from); + } + return finished; } - return finished; } from.trackTime += delta * from.timeScale; diff --git a/spine-csharp/src/package.json b/spine-csharp/src/package.json index f48f9357c..3d4bb86eb 100644 --- a/spine-csharp/src/package.json +++ b/spine-csharp/src/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-csharp", "displayName": "spine-csharp Runtime", "description": "This plugin provides the spine-csharp core runtime.", - "version": "4.2.32", + "version": "4.2.33", "unity": "2018.3", "author": { "name": "Esoteric Software",