How to Position and Size Gui objects correctly?

What I am trying to achieve?
Correct Positioning and Sizing of GUI objects in my game for every device’s display resolution.
What I have achieved so far?
Correctly Positioning the UI objects using AnchorPoint and Scale instead of Offset
What is the issue?
Using Scale as Size for Object causes it to not appear as intended on other resolutions, i.e, a square appears as a rectangle and much bigger in size, Using Offset causes the Position to change depending on the Screen Resolution, Is there a way to position and size the object as intended on every device?

It’s not a matter of using scale instead of offset. You want to use a blend of scale and offset. Scale is used for things that need to be flexible/responsive to screen size, while offset defines exact pixel values.

UIAspectRatioConstraint can be used to lock a scale sized element into a specific aspect ratio. An aspect ratio of 1 is a square.

Other UI Constraints that could help here are UISizeConstraint, and UITextSizeConstraint

1 Like

Thank you, UIAspectRatioConstraint seems to have worked perfectly

1 Like