Currently it is impossible to natively get the raw size of a GuiObject that has been altered with UIScale. AbsoluteSize
seems like the correct candidate for this, but it does have its limitations (in relation with UIScale, shown in the example).
Example
- you are creating a notification system, and therefore want to place TextLabels on under each other
- the TextLabels can have different text, meaning they can have varying sizes and therefore a predetermined size cannot be determined. The
Size
property won’t work as it will not change with AutomaticSize.AbsoluteSize
will have to be used to get the size of the TextLabel - you want to be able to animate the text labels into place, therefore UILayouts cannot be used as they cannot be animated
- you insert a UIScale instance to scale the UI so your code is able to scale it relative to the screen size
With a scale of 1, everything seems to be working perfectly:
It’s a different story when the scale is 2:
Workarounds
- find all instances of UIScale that is impacting the size of the gui (tedious)
- don’t use UIScale (doesn’t work with many workflows)
- use text service to retrieve the text bounds of text (doesn’t work with rich text, only works on text objects)
Proposed solutions
A property that tells you how much the GuiObject is being scaled.
A property or method that retrieves the size of the GuiObject before UIScale is applied