Is it necessary to manually kill tweens in Unity's DoTween library?

unity3d

#1

If I am tweening an object with DoTween library and I destroy the object before it’s tween is completed, will that cause any memory leakage? Should I kill all the tweens first manually before destroying the object?


#2

From ages ago when I used it I think the tweens are invalidated themselves.

If they leak or not is dependent on your usage. We were managing all our tweens and almost all that could be was pooled, along with proper destruction and communication of destruction onDestroy.

You can use DOTween.Validate() to get rid of invalidated tweens, which is expensive according to the documentation.

Best thing to do is just destroy and debug the behaviour yourself, DOTween is a bit convoluted in how it manages state internally but not completely incomprehensible.

Cheers


#3

Thanks. I figured keeping track of the tweens manually would be a good approach and this is exactly what I did, killing the tween on the game object before destroying the game object. In my project scope only a certain type of game objects have tweens so it wasn’t that hard to use this approach. :slight_smile: