Difference between all anchoredPosition, localPosition and pivotPosition ?

Hey all,
I’ve been searching around but I can’t seem to find a clear explanation that makes me understand the difference between anchoredPosition, localPosition and pivotPosition of a rectTransform and in what situation to use/set each one?

Also, what happens if you set the myUIObject.transform.Position externally, does it internally set one of those properties? I’m confused.

yourObject.GetComponent().anchoredPosition (or localPosition or pivotPosition)

Thanks in advance!

1 Like

RectTransform inherits from Transform.

RectTransform.position is the worldspace position.

RectTransform.localPosition is the position based on its parent’s coordinate system.

RectTrasnform.anchoredPosition is the object’s self-coordinate.(screenspace).It will be influenced by anchors and pivot.
5937734--635396--screenshot1.png

RectTransform’s pivotPosition is the original point(or balance point) of an ui object. If you change the pivot’s position, The localPosition and anchoredPosition will change with it, and also, the rotation and scale will have a different effect.
5937734--635402--screen3.gif

To understand this deeper, I suggest to turn on the inspector’s debug view and see how these values change.
5937734--635399--screen2.png

15 Likes

That was super helpful. Thank you very much! One extra question: So whats posX and posY in the inspector for a RectTransform referring to ? The anchoredPosition?

Yes.

1 Like

Thanks for your help man, appreciate it

Note that “Pos X” and “Pos Y” will not always be displayed at all. The inspector shows different variables in that area depending on how anchors are set.