It’s OK to use the animator…

You’re animating UI wrong? Well, not quite…

BIG note: one of the advantages of using e.g. LeanTween instead of the Unity Animator, according to this video, is performance. Whenever a UI element changes, the canvas gets dirtied/refreshed, which causes a performance hit. This is true regardless of whether you are using the Animator or LeanTween; the difference this video calls out is that the Animator dirties a canvas every frame whether it does anything or not!

Except not any more. This was a bug, and Unity has since fixed it. Repeat: Using a tweening library for UI animations no longer conveys a performance advantage.

However, the dirty/refresh system still leads to performance-boosting shenanigans: using multiple canvases in a single scene isolates dirty UI elements from each other, resulting in fewer objects processed per refresh.

LeanTween is still a useful tool in your kit, especially if, like me, you don’t especially like Unity’s animation tools. But there’s no easy integration between UI button state changes and LeanTween, and it’s good to know I can use the intended solutions as intended without shooting myself in the foot.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s