Skip to content

Actions execute after canceling LeanTween sequence #181

@rustobi

Description

@rustobi

Issue Description

When canceling a LeanTween sequence immediately after adding actions, the actions continue to execute even though the sequence was canceled. This behavior suggests that the cancellation does not immediately stop the sequence, leading to unexpected outputs.

Plattform
LeanTween version 2.50
Unity 2023.2.19f1

Steps to reproduce

  1. Create a sequence.
  2. Add a delay and some actions to the sequence.
  3. Cancel the sequence shortly after starting it.
  4. Observe that the actions in the sequence still execute.

Example code

public class LeanTweenCancelTest : MonoBehaviour
{
    private void Start()
    {
        SequenceTest();
        SequenceTest();
        SequenceTest();
        SequenceTest();
    }

    private async void SequenceTest()
    {
        LTSeq seq = LeanTween.sequence();

        Debug.Log($"[{Time.time}] Sequence started");
        seq.append(1f); // 1 second delay
        seq.append(() => Debug.Log($"[{Time.time}] I have started"));
        seq.append(LeanTween.move(gameObject, Vector3.one, 1f));
        seq.append(() => Debug.Log($"[{Time.time}] I'm done"));

        await Task.Delay(100); // Wait for 100 milliseconds
        Debug.Log($"[{Time.time}] Cancelling sequence with ID {seq.id}");
        LeanTween.cancel(seq.id);
    }
}

Expected behavior
The sequence should stop immediately upon calling LeanTween.cancel, and no further actions should be executed.

console output:

[0] Sequence started
[0] Sequence started
[0] Sequence started
[0] Sequence started
[0,01999999] Cancelling sequence with ID xxxxxx
[0,01999999] Cancelling sequence with ID xxxxxx
[0,01999999] Cancelling sequence with ID xxxxxx
[0,01999999] Cancelling sequence with ID xxxxxx

Actual behavior
Despite calling LeanTween.cancel, the actions in the sequence continue to execute.

console output:

[0] Sequence started
[0] Sequence started
[0] Sequence started
[0] Sequence started
[0,01999999] Cancelling sequence with ID xxxxxx
[0,01999999] Cancelling sequence with ID xxxxxx
[0,01999999] Cancelling sequence with ID xxxxxx
[0,01999999] Cancelling sequence with ID xxxxxx
[0,9922831] I have started
[1,986698] I'm done
[1,986698] I'm done
[1,986698] I'm done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions