When an ongoing tween is happening while an object is destroyed, an error is logged - with no way to disable? #70
-
Sorry if I'm missing something. I've noticed that .OnComplete() always has a "warn if null" flag; which i always set to false (i wish this was the default). However, I frequently have UI tweens which are ongoing when a UI panel is destroyed. I could keep track of these and kill manually, I know. But coming from DoTween, I didn't have to there, so why do I have to now? If there was at least a flag I'd set it every time, "kill tween if target is null" or something. I don't care if it's null checking every frame, that's fine in this case.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It is safe to destroy objects with running tweens, and there is no need to Stop() tweens manually before destroying an object or unloading a scene. Here is a separate article on this topic: #4 The error you get appears when you pass null (or destroyed) target to Tween.UISizeDelta() method. So to "disable" the error you need to check whether RectTransform != null. Or better: understand why RectTransform is null because this error typically indicates a bug in the user's code. If you get this error only when you destroy your UI panel, I assume you're trying to start an animation when the RectTransform has already been destroyed. A full stack trace can help understand what's happening exactly. |
Beta Was this translation helpful? Give feedback.
It is safe to destroy objects with running tweens, and there is no need to Stop() tweens manually before destroying an object or unloading a scene. Here is a separate article on this topic: #4
The error you get appears when you pass null (or destroyed) target to Tween.UISizeDelta() method. So to "disable" the error you need to check whether RectTransform != null. Or better: understand why RectTransform is null because this error typically indicates a bug in the user's code.
If you get this error only when you destroy your UI panel, I assume you're trying to start an animation when the RectTransform has already been destroyed. A full stack trace can help understand what's happening exactly.