Open Asterune
UDim2

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

Constructors3
Functions3
  • UDim2.fromOffset(xOffset: number?, yOffset: number?): UDim2

    Creates a value from horizontal and vertical pixel offsets with zero scales.

  • UDim2.fromScale(xScale: number?, yScale: number?): UDim2

    Creates a value from horizontal and vertical scales with zero pixel offsets.

  • UDim2.new(…)

    Creates a value from xScale, xOffset, yScale, yOffset, in that order.

Members2
Properties2

Constructors

fromOffset

UDim2.fromOffset(xOffset: number?, yOffset: number?): UDim2

Creates a value from horizontal and vertical pixel offsets with zero scales.

fromScale

UDim2.fromScale(xScale: number?, yScale: number?): UDim2

Creates 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: UDim

The horizontal dimension as a UDim.

Y

UDim2.Y: UDim

The vertical dimension as a UDim.

Operators

__add · __eq · __sub · __tostring · __type

Example

Luau
local size = UDim2.new(0.5, 0, 0, 40)

Used by

BillboardGui · Frame · ImageButton · ImageLabel · InputService · SceneFrame · ScrollingFrame · TextBox · TextButton · TextLabel · UIGridLayout

UDim · Vector2 · Frame · TextLabel