From 953c99939bb850b3d47bdd50fc57df5e58ae513c Mon Sep 17 00:00:00 2001 From: Andy Bond Date: Sat, 22 Aug 2020 16:17:59 -0700 Subject: [PATCH] - Check that the sequence counter matches the requested counter before canceling the tweens in the sequence. To reproduce the original behavior, save the uniqueId of a finished sequence, start a new sequence (it should occupy the same slot), and then attempt to cancel the original uniqueId. The new sequence will get canceled before it has a chance to do anything. --- Assets/LeanTween/Framework/LeanTween.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Assets/LeanTween/Framework/LeanTween.cs b/Assets/LeanTween/Framework/LeanTween.cs index 8bc23e41..17a2062b 100755 --- a/Assets/LeanTween/Framework/LeanTween.cs +++ b/Assets/LeanTween/Framework/LeanTween.cs @@ -627,17 +627,19 @@ public static void cancel( int uniqueId, bool callOnComplete ){ if (backId > tweens.Length - 1) { // sequence int sequenceId = backId - tweens.Length; LTSeq seq = sequences[sequenceId]; - // Debug.Log("sequenceId:" + sequenceId+" maxSequences:"+maxSequences+" prev:"+seq.previous); - - for (int i = 0; i < maxSequences; i++) { - if (seq.current.tween != null) { - int tweenId = seq.current.tween.uniqueId; - int tweenIndex = tweenId & 0xFFFF; - removeTween(tweenIndex); + if (seq.counter == backCounter) { + // Debug.Log("sequenceId:" + sequenceId+" maxSequences:"+maxSequences+" prev:"+seq.previous); + + for (int i = 0; i < maxSequences; i++) { + if (seq.current.tween != null) { + int tweenId = seq.current.tween.uniqueId; + int tweenIndex = tweenId & 0xFFFF; + removeTween(tweenIndex); + } + if (seq.current.previous == null) + break; + seq.current = seq.current.previous; } - if (seq.current.previous == null) - break; - seq.current = seq.current.previous; } } else { // tween // Debug.Log("uniqueId:"+uniqueId+ " id:"+backId +" action:"+(TweenAction)backType + " tweens[id].type:"+tweens[backId].type);