UDim2
Roblox-style 2D scale and offset value.
Syntax
UDim2.new(xScale?, xOffset?, yScale?, yOffset?) -> UDim2
UDim2.fromScale(x?, y?) -> UDim2
UDim2.fromOffset(x?, y?) -> UDim2
UDim2(xScale?, xOffset?, yScale?, yOffset?) -> UDim2
Parameters
| Parameter | Type | Description |
|---|---|---|
xScale | number | Horizontal scale, default 0. |
xOffset | number | Horizontal offset in pixels, default 0. |
yScale | number | Vertical scale, default 0. |
yOffset | number | Vertical offset in pixels, default 0. |
Returns
| Type | Description |
|---|---|
UDim2 | The constructed value. |
Description
fromScale sets both offsets to zero; fromOffset sets both scales to zero.
The userdata exposes XScale, XOffset, YScale and YOffset. X, Y, Width and Height return tables with Scale and Offset fields.
Example
local size = UDim2.new(0.5, 0, 0, 120)
print(size.X.Scale, size.Y.Offset)
print(typeof(size))
Notes
typeof(UDim2.new())reportsUDim2.- Arithmetic operators are not implemented yet.
- Generic GUI property writing is still required before assigning it to a real Instance.