Dotween: Completing tween with callbacks

Created on 30 Jul 2015  路  8Comments  路  Source: Demigiant/dotween

I would like to complete a tween in an instant, including all the callbacks. I found the following doesn't work.

Sequence seq = DOTween.Sequence();
seq.AppendCallback(() => Debug.Log("Doesn't work"));
...
seq.Complete();

Is this expected behaviour? If it is, what could be used as a workaround?

enhancement resolved

Most helpful comment

Yeah. Looks like it is specific to my scenario only. I need OnComplete so will add booleans for every animation. Anyway thank you for your help.

All 8 comments

Hi,

By design choice, Complete only completes animations, not callbacks. I thought about that a little more after you posted this, but logic-wise I believe it's better this way. The only callback that will work is OnComplete, so you could use this workaround instead:

Sequence s = DOTween.Sequence()
    .OnComplete(()=> Debug.Log("This will work"));
s.Complete();

Hi, thanks for the response, however, OnComplete isn鈥檛 suitable workaround in my scenario.

Basically, I have animation that also includes several callbacks in specific order (for operations such as changing sprites etc). Now I want to allow players to skip the animation. OnComplete won鈥檛 work because the they need to play in order.

Any ideas how to do this with DOTween?

Hi,

Forgot to answer here too, but just for reference the new update of DOTween includes an optional "withCallbacks" parameter to the Complete methods.

Please can you do that also for tweeners? I needed to disable callbacks

Hi,
It already works with Tweeners:
myTweener.Complete(true);
If instead you just want to disable callbacks, you just have to call Complete without parameters.

Sorry but I just check it, OnComplete callbacks is getting called after I call Complete().
I have Dotween Pro 0.9.690
Should I download new version to get it fixed?

Ah, wait, I misunderstood. OnComplete is the only callback that gets called every time, yes (because 99% of the times that's what one wants :P). In your case, you can delete the OnComplete callback completely:

myTween.OnComplete(null);
myTween.Complete(); // No callback happens

Yeah. Looks like it is specific to my scenario only. I need OnComplete so will add booleans for every animation. Anyway thank you for your help.

Was this page helpful?
0 / 5 - 0 ratings