Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.36k stars 350 forks source link

Strange issue with DOVirtual.DelayedCall(), later .Kill() and Auto Tween Recycling #421

Closed eintopf closed 4 years ago

eintopf commented 4 years ago

Hi,

we have a very strange issue (at two independent parts in our code) which seems to be a DoTween bug. At first: We are on the most recent AssetStore version (1.0.178). I also tried the newest bin files here on GitHub.

In one script we have a code like: closeTween = DOVirtual.DelayedCall(1.5f, () => ...)

closeTween is a field of the C# script. Problem: Sometimes this DelayedCall is never executed. Because it gets killed. I checked all usages of .Kill on this closeTween and none of our calls were executed. After quite some debugging I thought oh lets add an OnKill Callback and check the stacktrace. The interesting thing: The stacktrace comes from a completely different script where a completed different tween should be killed. It seems to be related to Tween Recycling, when i disable it in the DoTween preferences it seems to work correctly.

It is not "cleanly" reproducible, otherwise i'd create a repro project.

Hope someone can help on this issue since it is quite a danger for the whole project (since we use the delayedcalls here and there).

Best regards Bennet

eintopf commented 4 years ago

Ok, just found the respective bit in the documentation which states one should take care of dereferencing in OnKill.

So just in case someone else has this issue (foreach tween which does referencing): closeTween = DOVirtual.DelayedCall(1.5f, () => ...).OnKill(() => closeTween = null)