Skip to content

Fixed a bug with canceling an old sequence causing a new unrelated sequence to get canceled #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Assets/LeanTween/Framework/LeanTween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Author

@DoubleLoopAndy DoubleLoopAndy Aug 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this test, an unrelated sequence can be canceled.

// 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);
Expand Down