Reputation:
I was just curious if anybody here knows a bit about Unity RectTransform Anchors for? Basically, why have them at all? They just confused me. The other part of the question is how they affect the gameObject, this would really help me out with my UI development.
Upvotes: 3
Views: 3703
Reputation: 551
Anchor is useful for ensuring that your UI will maintain its position and size relative to the screen size. Let us say you have a UI design for a 16:9 device, if you play on a device with 4:3 resolution, that UI will not adjust and will probably take up most of the screen. With anchoring, how the UI will look in a 16:9 will adjust to a 4:3 device like how far will the sides be from the screen border, or how a button should always be at the top-right most part of the UI.
Upvotes: 1
Reputation: 8163
What do you mean by Anchors
?
if perhaps you mean RectTransform.anchoredPosition
, that is simply the pivot point of your UI object, relative to the anchor reference point.
if you are talking about the anchor reference points, they tell the UI object where to render and how to treat movements.
Think about it this way: you anchor something to the bottom of a window, and it will move up as you re-size the bottom of the window upward. if you anchor to the right of the window, the object will move left if you re-scale the right hand side of the window left.
Upvotes: 0