UI Layout and Rect Transform

As you may have noticed in the three preceding images, all UI objects are automatically given a Rect Transform component when they are created, as shown in the following screenshot:

UI Layout and Rect Transform

The Rect Transform component works similarly to the Transform component, in that it allows you to position the object. However, unlike Transform, it also has the properties of Width, Height, Pivot, and Anchors.

Tip

Remember that UI objects have the Rect Transform component, whereas other objects have the Transform component. It's important to realize the difference, especially if you try to access these components in code.

You can manually ...

Get Mastering Unity 2D Game Development - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.