Open Decavoid opened 10 months ago
I have a similar issue when killing a tween inside a sequence callback
Sequence sequence = DOTween.Sequence();
sequence.AppendCallback(() => {
DOTween.Kill("MyTween"))
// <- after the Kill line, the OnKill() method of MyTween is not yet called
};
Description:
When killing tweens inside another
OnComplete
callback, the correspondingOnKill
callback of the tween to be killed is not called immediately, synchronously. There is a checkTweenManager.isUpdateLoop
insideTween.Kill
that prevents it.OnKill
is called at some time in the future instead. As recommended in the docs, when recycling is enabled, we null the tween inOnKill
callback:.OnKill(()=> myTweenReference = null)
. The intention is to immediately kill the active tween and start another one as a replacement, assigning the new tween to the same variable. The current behavior (OnKill
is late) is nulling the replacement tween reference, thus the replacement tween can no longer be killed if needed.Proposal:
Raise
OnKill
callback always synchronously inKill()
, regardless ofTweenManager.isUpdateLoop
check.Test code:
Recycle tweens: enabled. Safe mode: true.
Expected console output:
Actual console output: