UDim and UDim2 constants

As a developer, it’s annoying to read and to write simple, frequently-used UDim and UDim2 structures. I want constants to represent these common structures.

UDim2 UDim2.zero --- UDim2.new(0, 0, 0, 0)
UDim2 UDim2.one --- UDim2.new(1, 0, 1, 0)
UDim2 UDim2.x --- UDim2.new(1, 0, 0, 0)
UDim2 UDim2.y --- UDim2.new(0, 0, 1, 0)
UDim UDim.zero --- UDim.new(0, 0)
UDim UDim.one --- UDim.new(1, 0)

But Sharksie, won’t it be confusing that the “one” value has offset 0?
No, because zero/one constants are useful for scalar properties. They aren’t useful for nominal properties like offset. No one will write UDim2.one expecting to get 1, 1, 1, 1 because that would be useless.

15 Likes

This should be added, UDim2.zero looks much more appealing than UDim2.new()

2 Likes

Following up on this - thanks for the feature request! We’re always on the lookout for ways to streamline working with UI, so we’re happy to consider these kinds of improvements.

While we might not implement exactly this feature request, this is a useful reference point for our ongoing discussions on how to make things better. So thank you for highlighting this - we’ll see what we can do to make UDim more ergonomic to work with.

If you have specific use cases or code examples to highlight how the current APIs aren’t working well for you, we would love to incorporate those into our discussions :slightly_smiling_face:

2 Likes