Demigiant / dotween

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

OnComplete doesn't called when SetLoops(-1) #566

Closed Sargerus closed 2 years ago

Sargerus commented 2 years ago

` public GameObject asd; private Tweener tw;

void Start()
{
    tw = asd.transform.DOPunchScale(Vector3.one * 2, 2)
        .OnComplete(() => { Debug.Log("Complete"); })
        .SetLoops(-1); //SetLoops(2)
}

void Update()
{
    if (Input.GetKeyDown(KeyCode.Q))
        tw.Complete();
}`

It is easy to reproduce. Pressing Q button won't trigger tweeners OnComplete() until you make SetLoops(any natural number).

Demigiant commented 2 years ago

If your tween loops infinitely (aka loops set to -1) it can't complete (not only the OnComplete callback won't fire, but also the animation will continue playing because Complete is ignored) :P If you want a callback when a "loop step" completes you can use OnStepComplete, or if you want to be able to complete a semi-infinite loop cycle you can set its loops to int.MaxValue