From d4242a82574c91c0c1cb1a74c39b8ade3ac6815f Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 20 Mar 2024 17:39:37 +0100 Subject: [PATCH] [csharp] Port of commit 88b009c: AnimationState, improved triggering complete event. --- spine-csharp/src/AnimationState.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 83f01a231..979bb4896 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -595,9 +595,14 @@ namespace Spine { // Queue complete if completed a loop iteration or the animation. bool complete = false; - if (entry.loop) - complete = duration == 0 || (trackLastWrapped > entry.trackTime % duration); - else + if (entry.loop) { + if (duration == 0) + complete = true; + else { + int cycles = (int)(entry.trackTime / duration); + complete = cycles > 0 && cycles > (int)(entry.trackLast / duration); + } + } else complete = animationTime >= animationEnd && entry.animationLast < animationEnd; if (complete) queue.Complete(entry);