Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[S] Is it possible to get the actual pixel size of a GUI which is using an UIAspectRatioConstraint?

Hello all,

I have a bit of a wierd question, I can obviously use print(script.ViewportFrame.Size.Y) to return the properties of a GUIs Y size which are manually set/by a script BUT because I'm using an UIAspectRatioConstraint (AspectRatio = 1, AspectType = FitWithinMaxSize, DominantAxis = width) the Y size is actually limited to be of a ratio of X size.

Y = {1,0}, X = {0.33, 0} Y is limited by X so its not actually {1,0}

I hope you're following...

So, if the X size is {0.33, 0} the Y size is also limited to the aspect ratio, you might think oh then Y size = {0.33, 0} but thats not the case because this is in an oblong frame (a scrolling frame) so the scales are not the same.

Now for the question...

Can I get the actual display Y size (preferably in pixels / offset) which is a ratio of X or will the properties size of Y always be returned (like in the code of the first paragraph)?

1 comment

0

Please ask for any clarification if this isn't phrased well enough :S :)

1 answer

I think I have an answer:

Using ViewportFrame.AbsoluteSize.Y will give the pixel size of the GUI. This also works when the GUI has an overriding aspect ratio lock.

I took a different approach to solving my problem in the end (using GridLayouts) and stumbled across this while trying to solve a different problem!

Hopefully this helps! especially those who have upvoted (TY!)

This discussion is preserved as it was. New answers, comments, and votes are closed.