diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 9f310a0b8..2adf50a93 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -694,8 +694,12 @@ namespace Spine { return SetAnimation(trackIndex, animation, loop); } - /// Sets the current animation for a track, discarding any queued animations. If the formerly current track entry was never - /// applied to a skeleton, it is replaced (not mixed from). + /// + /// Sets the current animation for a track, discarding any queued animations. + /// + /// If the formerly current track entry is for the same animation and was never applied to a skeleton, it is replaced (not mixed + /// from). + /// /// If true, the animation will repeat. If false it will not, instead its last frame is applied if played beyond its /// duration. In either case determines when the track is cleared. /// A track entry to allow further customization of animation playback. References to the track entry must not be kept @@ -705,7 +709,7 @@ namespace Spine { bool interrupt = true; TrackEntry current = ExpandToIndex(trackIndex); if (current != null) { - if (current.nextTrackLast == -1) { + if (current.nextTrackLast == -1 && current.animation == animation) { // Don't mix from an entry that was never applied. tracks.Items[trackIndex] = current.mixingFrom; queue.Interrupt(current); diff --git a/spine-csharp/src/package.json b/spine-csharp/src/package.json index dfc126b16..bb824c165 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. Compatible with skeleton exports from Spine Editor version 4.3.40-beta or later.", - "version": "4.3.16", + "version": "4.3.17", "unity": "2018.3", "author": { "name": "Esoteric Software", diff --git a/spine-csharp/tests/package.json b/spine-csharp/tests/package.json index fae5b84d7..1b2942192 100644 --- a/spine-csharp/tests/package.json +++ b/spine-csharp/tests/package.json @@ -2,7 +2,7 @@ "name": "com.esotericsoftware.spine.spine-csharp-tests", "displayName": "spine-csharp Runtime Tests", "description": "This plugin provides tests for the spine-csharp core runtime.", - "version": "4.3.0", + "version": "4.3.1", "unity": "2018.3", "author": { "name": "Esoteric Software", diff --git a/spine-csharp/tests/src/AnimationStateTests.cs b/spine-csharp/tests/src/AnimationStateTests.cs index 5321d5414..a9e912936 100644 --- a/spine-csharp/tests/src/AnimationStateTests.cs +++ b/spine-csharp/tests/src/AnimationStateTests.cs @@ -602,11 +602,13 @@ namespace Spine { Setup("setAnimation twice", // 21 Expect(0, "start", 0, 0), // Expect(0, "interrupt", 0, 0), // - Expect(0, "end", 0, 0), // - Expect(0, "dispose", 0, 0), // Expect(1, "start", 0, 0), // Expect(1, "event 0", 0, 0), // + + Expect(0, "end", 0, 0.1f), // + Expect(0, "dispose", 0, 0.1f), // + Expect(1, "event 14", 0.5f, 0.5f), // Note("First 2 setAnimation calls are done."), @@ -615,8 +617,6 @@ namespace Spine { Expect(0, "start", 0, 0.8f), // Expect(0, "interrupt", 0, 0.8f), // - Expect(0, "end", 0, 0.8f), // - Expect(0, "dispose", 0, 0.8f), // Expect(2, "start", 0, 0.8f), // Expect(2, "event 0", 0.1f, 0.9f), // @@ -624,18 +624,21 @@ namespace Spine { Expect(1, "end", 0.9f, 1), // Expect(1, "dispose", 0.9f, 1), // + Expect(0, "end", 0.1f, 1), // + Expect(0, "dispose", 0.1f, 1), // + Expect(2, "event 14", 0.5f, 1.3f), // Expect(2, "event 30", 1, 1.8f), // Expect(2, "complete", 1, 1.8f), // Expect(2, "end", 1, 1.9f), // Expect(2, "dispose", 1, 1.9f) // ); - state.SetAnimation(0, "events0", false); // First should be ignored. + state.SetAnimation(0, "events0", false); // Kept as mixingFrom (not discarded, different animation). state.SetAnimation(0, "events1", false); Run(0.1f, 1000, new TestListener( (time) => { if (IsEqual(time, 0.8f)) { - state.SetAnimation(0, "events0", false); // First should be ignored. + state.SetAnimation(0, "events0", false); // Kept as mixingFrom (not discarded, different animation). state.SetAnimation(0, "events2", false).TrackEnd = 1; } })); @@ -643,8 +646,6 @@ namespace Spine { Setup("setAnimation twice with multiple mixing", // 22 Expect(0, "start", 0, 0), // Expect(0, "interrupt", 0, 0), // - Expect(0, "end", 0, 0), // - Expect(0, "dispose", 0, 0), // Expect(1, "start", 0, 0), // Expect(1, "event 0", 0, 0), // @@ -655,8 +656,6 @@ namespace Spine { Expect(0, "start", 0, 0.2f), // Expect(0, "interrupt", 0, 0.2f), // - Expect(0, "end", 0, 0.2f), // - Expect(0, "dispose", 0, 0.2f), // Expect(2, "start", 0, 0.2f), // Expect(2, "event 0", 0.1f, 0.3f), // @@ -667,36 +666,43 @@ namespace Spine { Expect(1, "start", 0, 0.4f), // Expect(1, "interrupt", 0, 0.4f), // - Expect(1, "end", 0, 0.4f), // - Expect(1, "dispose", 0, 0.4f), // Expect(0, "start", 0, 0.4f), // Expect(0, "event 0", 0.1f, 0.5f), // + Expect(0, "end", 0.6f, 0.7f), // + Expect(0, "dispose", 0.6f, 0.7f), // + Expect(1, "end", 0.8f, 0.9f), // Expect(1, "dispose", 0.8f, 0.9f), // + Expect(0, "end", 0.6f, 0.9f), // + Expect(0, "dispose", 0.6f, 0.9f), // + Expect(0, "event 14", 0.5f, 0.9f), // Expect(2, "end", 0.8f, 1.1f), // Expect(2, "dispose", 0.8f, 1.1f), // + Expect(1, "end", 0.6f, 1.1f), // + Expect(1, "dispose", 0.6f, 1.1f), // + Expect(0, "event 30", 1, 1.4f), // Expect(0, "complete", 1, 1.4f), // Expect(0, "end", 1, 1.5f), // Expect(0, "dispose", 1, 1.5f) // ); stateData.DefaultMix = 0.6f; - state.SetAnimation(0, "events0", false); // First should be ignored. + state.SetAnimation(0, "events0", false); // Kept as mixingFrom (not discarded, different animation). state.SetAnimation(0, "events1", false); Run(0.1f, 1000, new TestListener( (time) => { if (IsEqual(time, 0.2f)) { - state.SetAnimation(0, "events0", false); // First should be ignored. + state.SetAnimation(0, "events0", false); // Kept as mixingFrom (not discarded, different animation). state.SetAnimation(0, "events2", false); } if (IsEqual(time, 0.4f)) { - state.SetAnimation(0, "events1", false); // First should be ignored. + state.SetAnimation(0, "events1", false); // Kept as mixingFrom (not discarded, different animation). state.SetAnimation(0, "events0", false).TrackEnd = 1; } }));