I need to have an UI element to scale for half the screen.
At the moment I have on element that is stretched for the whole screen and then i just set the X scale to 0.5 and change the pivot. But this approach makes all the UI child elements like images and texts also only 0.5 on scale.
I need a way scale the UI element to half the screen without all the children elements also has half the width.
That’s why you can change the anchors manually, not only with the “anchor” dropdown.
Look at the RectTransform component and you’ll see an “Anchors” that is actually an array with 2 vectors with min x and max x, and min y and max y.
If you want the element to take the left half of the screen use this anchors:
min x = 0, max x = 0.5, min y = 0, max y = 1
For the right half:
min x = 0.5, max x = 1, min y = 0, max y = 1
For bottom and top halfs do the same but with the y anchors.
If you want something that’s half of the screen width and height but it’s also centered do this:
min x = 0.25, max x = 0.75, min y = 0.25, max y = 0.75