How to get RectTransform values of game object

Every game object in Unity 4.6 has a RectTransform that has x, y, z, width and height. Is there ant way to get these values within a C# script?

1 Like

yourObject.GetComponent().anchoredPosition (or localPosition or pivotPosition), depending on your needs.

3 Likes

Note that the values you see in the inspector are not necessarily what you use in code, since the default RectTransform inspector consolidates some things to make it easier to edit visually. Switch to debug mode for the “real” values. Also read the RectTransform scripting docs to see what the properties are.

–Eric

1 Like