Tip: Learning how to script stuff in the new UI?

It’s been a common problem here that many people have had: “How do I script X to happen on RectTransforms?” The RectTransform inspector is very helpful for laying out, less helpful for making script functionality discoverable.

The trick to learning what property does what: animation. Create a temporary Animator and AnimationClip, and in the editor (using record mode), move the UI element as you would like the script to change things. Now, look at what properties have been animated in the animation timeline. Those are the properties you want to set in your script!

8 Likes

Came here looking for an answer to a specific problem. Left with the tools I needed to figure it out on my own.

Thank you!

3 Likes