# Udim2

## Overview

UDim2는 가로(X)와 세로(Y) 두 방향의 값을 함께 다루는 데이터 타입으로, 각 방향마다 전체 크기에 비례하는비율 값과 고정된 픽셀 단위의 보정 값을 함께 포함합니다. UI 요소의 크기나 화면 내 위치를 유연하게 지정할 때 가장 많이 활용됩니다.

## Constructors

### new

X축과 Y축에 대해 전달된 스케일 값과 오프셋 값을 기반으로 하나의 UDim2 객체를 생성하여 반환합니다. 생성된 UDim2는 UI의 위치나 크기를 직접 지정할 때 사용할 수 있습니다.

#### Parameters

| `number` xScale  | 부모 요소의 크기를 기준으로 X축 방향에 적용되는 상대적인 비율 값입니다. |
| ---------------- | ----------------------------------------- |
| `number` xOffset | X축 방향에 픽셀 단위로 적용되는 절대 값입니다.               |
| `number` yScale  | 부모 요소의 크기를 기준으로 Y축 방향에 적용되는 상대적인 비율 값입니다. |
| `number` yOffset | Y축 방향에 픽셀 단위로 적용되는 절대 값입니다.               |

#### Return

| `UDim2` | 지정된 스케일 및 오프셋 값으로 구성된 UDim2입니다. |
| ------- | ------------------------------- |

#### Code Samples

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

TextLabel.Position = Position
```

## Properties

### X

`UDim`

X축 방향에 적용되는 상대적인 스케일 값과 픽셀 기준의 오프셋 값을 함께 나타냅니다.

#### Code Samples

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

print(Position.X.Scale, Position.X.Offset)
```

### Y

`UDim`

Y축 방향에 적용되는 상대적인 스케일 값과 픽셀 기준의 오프셋 값을 함께 나타냅니다.

#### Code Samples

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

print(Position.Y.Scale, Position.Y.Offset)
```

## Methods

### Lerp

현재 Dim2와 목표 Dim2 사이를 선형 보간 방식으로 alpha 비율에 따라 계산한 위치를 새로운 Dim2로 반환합니다.

#### Parameters

| `UDim2` GoalValue | 보간의 대상이 되는 목표 Dim2입니다. |
| ----------------- | ---------------------- |
| `number` Alpha    | 보간 비율을 나타내는 값입니다.      |

#### Return

| `UDim2` | 생성된 UDim2입니다. |
| ------- | ------------- |

#### Code Samples

```lua
local a = UDim2.new(0.0, 0, 0.1, 0)
local b = UDim2.new(0.1, 100, 0.1, 100)
print(a:Lerp(b, 0.3)) --> Output: {0.03, 30}, {0.1, 30}
```

## Events

## See also

{% content-ref url="/pages/mC9duPphkAklv8ZEUCpW" %}
[좌표계](/korean/manual/studio-manual/get-started/coordinate-system.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overdare.com/korean/development/api-reference/datatype/udim2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
