Skip to content
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

Actions execute after canceling LeanTween sequence #181

Open
rustobi opened this issue Jul 3, 2024 · 0 comments
Open

Actions execute after canceling LeanTween sequence #181

rustobi opened this issue Jul 3, 2024 · 0 comments

Comments

@rustobi
Copy link

rustobi commented Jul 3, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant