Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i keep a GUI proportional?

Asked by 8 years ago

Lets say I have a trading card I want to display on screen. In order to not get stretched images, the height and width must be proportional in pixels.

A trading card is about 2.43 inches wide and 3.43 inches tall. Thus you can represent it with UDim2.new(0, 243, 0, 343) and it would look just fine. However, something like UDim2.new(.243, 0, .343, 0) Would not work as the screen stretches the GUI.

The dilemma is, how would I get the GUI to size itself proportionally to the screen so it remains cross compatiable, yet keep a constant ratio of height and width?

1 answer

Log in to vote
2
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

If you set the SizeConstraint to RelativeXX or RelativeYY, the scale factors will both be in terms of either the width or height of the screen so the values will represent the same lengths.

0
Works just as I need it. Thanks! randomsmileyface 375 — 8y
0
Nice but I would argue that you could just use the scale part of the UDim2 which is UDim2.new(xscale,ypixels,yscale,ypixels) User#5978 25 — 8y
0
it is scale. 1waffle1 2908 — 8y
Ad

Answer this question