Nested sequencedTweens doesn't complete ok Kill method
Hello,
First of all thank you for DOTween!
I use sub sequnces a lot. And I have a problem, when I use DOTween.Kill(gameObject, true); I expect that all tween will complete, but only top level sequence receive this state. Moreover sub sequnces/tweens don't finaliase its states.
So I've tried to find some workaround. I've patched TweenManager.cs "Complete" method like this:
internal static bool Complete(Tween t, bool modifyActiveLists = true)
{
if (t.loops == -1) return false;
if (!t.isComplete) {
//////////////////////////////////////////////////////////////////////////////
// FIX: PI: Fixed situation when nested sequences doesn't tweens till end
if (t.tweenType == TweenType.Sequence)
{
Sequence s = (Sequence)t;
int len = s.sequencedTweens.Count;
for (int i = 0; i < len; ++i)
Complete(s.sequencedTweens[i], modifyActiveLists);
}
//////////////////////////////////////////////////////////////////////////////
Tween.DoGoto(t, t.duration, t.loops, UpdateMode.Goto);
t.isPlaying = false;
// Despawn if needed
if (t.autoKill) {
if (isUpdateLoop) t.active = false; // Just mark it for killing, so the update loop will take care of it
else Despawn(t, modifyActiveLists);
}
return true;
}
return false;
}
Can you please check this approach or provide better solution for this issue?
Fixed in v1.0.350
Hi Igor,
thanks a lot for looking into this and finding a workaround. I actually just fixed it in a different way, because Tween.DoGoto should complete nested tweens so I looked into that (and found an issue with a misplaced line in Sequence.DoApplyTween), but it greatly helped me to find it.
Download compiled v1.0.350 from here (or from the repo).
Btw, here is another issue that prevent call OnComplite if subsequence is appended last to sequence.
Sequence s1 = DOTween.Sequence(); Sequence s2 = DOTween.Sequence();
s1.OnComplete() => will call s2.OnComplete() => will NOT call
Sequence s = DOTween.Sequence();
s.Append(s1); s.Append(s2); ... s.OnComplete() => will call
Can you check if it's working for you with the previous update? I just checked and all the callbacks are being called here.