Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.33k stars 348 forks source link

Sequence callback behaviour when pausing is wrong or unclear #548

Open IsCool-ClementMarchal opened 2 years ago

IsCool-ClementMarchal commented 2 years ago

The behaviours of callbacks in a sequence is either bugged or unclear.

In a simple project with a monobehaviour with

public class Test : MonoBehaviour
{
    public GameObject cube;

    private Sequence mySequence;

    private void Start()
    {
        mySequence = DOTween.Sequence();

        mySequence.Append(cube.transform.DOMoveX(1f, 1f));
        mySequence.AppendCallback(() => Debug.Log("After DoMoveX"));

        mySequence.AppendCallback(() => mySequence.Pause());
        mySequence.AppendCallback(() => Debug.Log("After First Pause"));

        mySequence.Append(cube.transform.DOMoveY(1f, 1f));
        mySequence.AppendCallback(() => Debug.Log("After DoMoveY"));

        mySequence.AppendCallback(() => mySequence.Pause());
        mySequence.AppendCallback(() => Debug.Log("After Last Pause"));
    }

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
            mySequence.Play();
    }
}

As I understand, the expected behaviour should be: -Upon start, the Sequence is created and auto-played. (cube starts on (0;0)) -The Tweener DoMoveX moves the cube to (1;0) in 1 second. -The callback logs "After DoMoveX" -The sequence pauses itself -Upon pressing space, the sequence resumes, and callback logs "After First Pause" -The Tweener DoMoveY moves the cube to (1;1) in 1 second. -The callback logs "After DoMoveY" -The sequence pauses itself -Upon pressing space, the sequence resumes, and callback logs "After Last Pause" -The sequence completes, and auto-kills itself

But in practice: -The callback logging "After First Pause" is never called -The callback logging "After Last Pause" is called immediately without waiting for the sequence to resume