UDim2
Combines scale and pixel offset for two-dimensional GUI layout.
Behavior
UDim2 stores horizontal and vertical UDim values. Each axis
combines a fraction of the parent dimension with a pixel offset.
UDim2.new(0.5, 0, 0, 40) specifies half the parent width and a height of 40 pixels.
Summary
Creates a value from horizontal and vertical pixel offsets with zero scales.
Creates a value from horizontal and vertical scales with zero pixel offsets.
Creates a value from xScale, xOffset, yScale, yOffset, in that order.
Constructors
fromOffset
UDim2.fromOffset(xOffset: number?, yOffset: number?): UDim2Creates a value from horizontal and vertical pixel offsets with zero scales.
fromScale
UDim2.fromScale(xScale: number?, yScale: number?): UDim2Creates a value from horizontal and vertical scales with zero pixel offsets.
new
UDim2.new(…)Creates a value from xScale, xOffset, yScale, yOffset, in that order.
Properties
X
UDim2.X: UDimThe horizontal dimension as a UDim.
Y
UDim2.Y: UDimThe vertical dimension as a UDim.
Operators
__add · __eq · __sub · __tostring · __type
Example
local size = UDim2.new(0.5, 0, 0, 40)Used by
BillboardGui · Frame · ImageButton · ImageLabel · InputService · SceneFrame · ScrollingFrame · TextBox · TextButton · TextLabel · UIGridLayout