1

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");
}
Raoul L'artiste
  • 160
  • 1
  • 8
  • 1
    Beware the _[train wreck anti-pattern](https://wiki.c2.com/?TrainWreck)_ –  Aug 02 '22 at 00:35
  • @MickyD unfortunatelly it is how [DoTween](http://dotween.demigiant.com/documentation.php) works though ;) Of curse you could split them up in multiple lines though – derHugo Aug 02 '22 at 07:27

2 Answers2

2

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;
JDormer
  • 285
  • 1
  • 10
0

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());
rbcode
  • 327
  • 2
  • 7
  • `onComplete(() => ResetUnlock())` and `onComplete(ResetUnlock)` would basically be equivalent just that you introduced a lambda around it – derHugo Aug 02 '22 at 07:25
  • This is the better option if you are trying to define the logic procedurally and won't necessarily know what you want `OnComplete` to call, but yea for this simple example it will achieve the same result – JDormer Aug 02 '22 at 20:33