dotween icon indicating copy to clipboard operation
dotween copied to clipboard

Tween sequence does not call onComplete every time

Open pushkin opened this issue 4 years ago • 2 comments

Versions: Unity 2019.4.13f1 and DOTween v1.2.420

Bug: The fadeSecquence below does not call onComplete (FadeComplete) 100% of the time.

Reproduce: Instantiate a new GameObject with the component below and let the animations run (assign the text variable). Instantiate the GameObjects in rapid succession e.g. from a button press. The fadeSecquence will not complete every time in my tests. If I remove the fadeSecquence and use two DOFades with delays it will work every time.

public class AnimatedText : MonoBehaviour
{
    [SerializeField] TMP_Text text;

  void Start()
  {
    Sequence fadeSecquence = DOTween.Sequence();
    fadeSecquence.AppendInterval(delay);
    fadeSecquence.Append(text.DOFade(1, fadeDuration));
    fadeSecquence.AppendInterval(duration - fadeDuration);
    fadeSecquence.Append(text.DOFade(0, fadeDuration));
    fadeSecquence.onComplete = FadeComplete;

    gameObject.transform.DOMoveY(10, 2).onComplete = MoveComplete;
  }

  void MoveComplete()
  {
   
  }  

  void FadeComplete() // This is not called 100% of the time
  {
   
  }
}

If I change the fadeSecquence to the below code it works 100% of the time:
text.DOFade(1, fadeDuration).SetDelay(delay); text.DOFade(0, fadeDuration).SetDelay(duration - fadeDuration).onComplete = FadeComplete;

Additionally if I remove the DOMoveY it also works 100% of the time.

Glad to give more info if needed.

Screenshot 2021-06-22 at 13 12 17 Screenshot 2021-06-22 at 13 12 12

pushkin avatar Jun 22 '21 10:06 pushkin

+1

vahagn-harutyunyan avatar Jul 28 '22 19:07 vahagn-harutyunyan

+1

SilentGamzee avatar Mar 30 '23 13:03 SilentGamzee