- Home /
Questions about UGUI Rect Transform Anchors. How to make UI objects scale, correctly, with screen?
There's something that's been bothering me about the UGUI ui and the way it works.
I want my objects to scale evenly when the screen scales and the only effective way I've found to do this is to carefully place the anchors, by hand, on the boundaries of the rect transform. Here's an example:
There's really no easy way to do this. There's many ways to control the anchors, but none of them seem to do what I want and none of them accommodate for this. This shows up as custom/custom. And there's no good way in custom mode, like this, to resize the rect in the inspector. Instead of a height or a width there is a left, top, right, and bottom that doesn't really seem to make a lot of sense to me. The anchors min/max x and y don't make a lot of sense to me either.
Example:
If you do move or resize the rect the anchors don't follow and there's no good way, I know of, to move them back to the corners(Edit: I just found uGUI tools script which does exactly that). I think the rect will snap to the anchors, though, but that doesn't really help in moving the rect.
So, am I missing something that would make this all work a lot better for me? Or is this uGUI's intended behavior, it just wasn't well designed for what I want to do?
I guess, for now, unless someone tells me differently, when I want to make a UI object a specific size, I will switch the anchors to a mode that allows that, and then I'll use the uGUI tools script I just found set the anchors back to the corners. Silly that Unity doesn't include that.
Answer by Zionmoose · Jul 02, 2017 at 05:24 PM
Little late to the game, but you can use something like this. It's a free asset that does exactly as you ask. I use it myself.
Your answer
Follow this Question
Related Questions
Convert Input.mousePosition to RectTransform pivot position 2 Answers
How to change the Top and Bottom (rect.yMin and yMax) properties of a rectTransform, in a script? 2 Answers
Change size of the new UI rect transform using scripts 0 Answers
UI How to configure Left And Right. 1 Answer
Using Unity New UI, duplicated UI objects created with Scale 0, 0, 0 1 Answer