Home > Back-end >  DoTween. how to call a function when Tween has finished?
DoTween. how to call a function when Tween has finished?

Time:08-02

I couldn't find anything in their documentation but I'm really stuck with how to call a function, once DoTween has finished the tween. :/ Does anyone know?

I tried this but I get an error onComplete does not take an argument.

unlocked.DOSizeDelta(Vector2.one, .3f).SetEase(Ease.InBack).onComplete(ResetUnlock);


private void ResetUnlock()
{
    print("dosomething");
}

CodePudding user response:

OnComplete is just a TweenCallback delegate. So you just need to assign it like so.

unlocked.DOSizeDelta(Vector2.one, .3f).SetEase(Ease.InBack).onComplete = ResetUnlock;

CodePudding user response:

as JDormer mentioned its a TweenCallback delegate. You can use a lambda function (anonymous delegate) with no parameters to call your ResetUnlock() method.

unlocked.DOSizeDelta(Vector2.one, .3f).SetEase(Ease.InBack).onComplete(() => ResetUnlock());
  • Related