Udim2

Overview

UDim2 is a data type that handles values in both horizontal (X) and vertical (Y) directions. For each direction, it includes both the scale value proportional to the entire size and fixed offset correction value in pixel. It is mostly used when flexibly specifying the size or position of UI elements on the screen.

Constructors

new

Creates a single UDim2 object based on the passed scale value for X axis and Y axis, and returns it. The created UDim2 can be used to manually specify the position or size of UI.

Parameters

number xScale

The scale value applied along the X axis relative to the size of parent.

number xOffset

The absolute value applied along the X axis in pixel.

number yScale

The scale value applied along the Y axis relative to the size of parent.

number yOffset

The absolute value applied along the Y axis in pixel.

Return

UDim2

The UDim2 consisted of the specified scale and offset values.

Code Samples

local Position = UDim2.new(0.5, 10, 0.5, 20)

TextLabel.Position = Position

Properties

X

It represents both the relative scale value and offset value in pixel applied along the X axis.

Code Samples

Y

It represents both the relative scale value and offset value in pixel applied along the Y axis.

Code Samples

Methods

See also

Coordinate System

Last updated