Offset and Scale constructors for UDim2

As a developer, I often find myself only using scale or only using offset frequently when defining UDim2 values. This is somewhat awkward to write because I need to space my relevant values around 0’s properly, and it can take longer for your eyes to fully parse a UDim2 declaration. To remedy this, I’d like to be able to create new UDim2 objects with constructors for just scale, or just offset:

UDim2.offset(offsetX, offsetY) -- equivalent to UDim2.new(0, offsetX, 0, offsetY)
UDim2.scale(scaleX, scaleY) -- equivalent to UDim2.new(scaleX, 0, scaleY, 0)

This would make UDim2 definitions cleaner and faster to read in a lot of places, and easier to understand in a momentary glace, as your eye doesnt have to linger to try to parse over the positions of the 0’s. This would also make writing these definitions less cumbersome.

15 Likes

This would be really handy but also could be API bloat. It’s not like it’s impossible to size or position GUIs with the current method, it’s just really cumbersome.

All the same, I 100% support such a feature because it will save some time when coding UI, which is currently slow and annoying.

4 Likes

I rarely find myself using both scale and offset, so this would make my code a lot more readable.

1 Like