Button

Button

ν΄λΌμ΄μ–ΈνŠΈμ—μ„œ μ‚¬μš©λ˜λŠ” Widget Button 객체.

이벀트

λ²„νŠΌμ΄ 눌릴 λ•Œ ν˜ΈμΆœλ˜λŠ” μ΄λ²€νŠΈμ—μš”. μ—°κ²°ν•¨μˆ˜ ν˜•μ‹μ€ function(pressButton), pressButton λŠ” 눌린 μœ„μ ―λ²„νŠΌ 객체 μž…λ‹ˆλ‹€.

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button

local function PressEvent(self) --OnPressEvent둜 μ—°κ²°λœ ν•¨μˆ˜λŠ” self μΈμžκ°€ κ³ μ •μ μœΌλ‘œ λ“€μ–΄κ°€μš”.
    print(self.Name .. " Button Click!")
end
button.OnPressEvent:Connect(PressEvent) --λ²„νŠΌμ— ν•΄λ‹Ή λ²„νŠΌμ΄ λˆŒλ Έμ„λ•Œ ν˜ΈμΆœλ˜λŠ” ν•¨μˆ˜λ₯Ό μ—°κ²°ν•΄μš”.

λ²„νŠΌμ΄ λˆŒλ Έλ‹€κ°€ λ–Όμ–΄μ§ˆ λ•Œ ν˜ΈμΆœλ˜λŠ” μ΄λ²€νŠΈμ—μš”. μ—°κ²°ν•¨μˆ˜ ν˜•μ‹μ€ function(upButton), upButton λŠ” λˆŒλ Έλ‹€κ°€ 떼어진 μœ„μ ―λ²„νŠΌ 객체 μž…λ‹ˆλ‹€.

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button

local function UpEvent(self) --OnUpEvent둜 μ—°κ²°λœ ν•¨μˆ˜λŠ” self μΈμžκ°€ κ³ μ •μ μœΌλ‘œ λ“€μ–΄κ°€μš”.
    print(self.Name .. " Button Click!")
end
button.OnUpEvent:Connect(UpEvent) --λ²„νŠΌμ— ν•΄λ‹Ή λ²„νŠΌμ΄ λˆŒλ Έλ‹€κ°€ λ–Όμ–΄μ§ˆ λ•Œ ν˜ΈμΆœλ˜λŠ” ν•¨μˆ˜λ₯Ό μ—°κ²°ν•΄μš”.

속성

λ²„νŠΌ μ΄λ―Έμ§€μ˜ DrawType을 μ„€μ •ν•˜κ³  얻을 수 μžˆμ–΄μš” (None, Tile, Slice, Border).

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button

button.ImageDrawType = Enum.ImageDrawType.Image

λ²„νŠΌ μ΄λ―Έμ§€μ˜ DrawType이 Slice, Border일 λ•Œμ˜ Slice μ’Œμš°μ˜μ—­(각각 0λΆ€ν„° 1사이)을 μ •ν•˜κ³  얻을 수 μžˆμ–΄μš”(Left, Right).

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button

button.ImageDrawType = Enum.ImageDrawType.Slice
button.SliceLeftRight = Vector.new(0.5, 0.5, 0) --X : 쒌 / Y : 우

λ²„νŠΌ μ΄λ―Έμ§€μ˜ DrawType이 Slice, Border일 λ•Œμ˜ Slice μ’Œμš°μ˜μ—­(각각 0λΆ€ν„° 1사이)을 μ •ν•˜κ³  얻을 수 μžˆμ–΄μš”(Top, Bottom).

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button

button.ImageDrawType = Enum.ImageDrawType.Slice
button.SliceTopBottom = Vector.new(0.5, 0.5, 0) --X : 상 / Y : ν•˜

λ²„νŠΌ μ΄λ―Έμ§€μ˜ DrawType이 Tile일 λ•Œμ˜ μ˜΅μ…˜κ°’μ„ μ„€μ •ν•˜κ³  얻을 수 μžˆμ–΄μš” (NoTile, Horizontal, Vertical, Both)

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button

button.ImageDrawType = Enum.ImageDrawType.Image
button.ImageTiling = Enum.ImageTilingType.Both

ν•¨μˆ˜

(X.0 , X) 값은 λͺ¨λ‘ X둜 λ°˜ν™˜λ˜μ„œ 좜λ ₯λ©λ‹ˆλ‹€. X.0을 좜λ ₯ν•˜κ³  μ‹ΆμœΌλ©΄ tostring으둜 λ³€ν™˜ν›„ μ΄μš©ν•΄μ£Όμ„Έμš” μœ„μ ―μ˜ ν…μŠ€νŠΈλ₯Ό 주어진 μ‹€μˆ˜λ‘œ λ³€κ²½ν•΄μš”. ( λ³€κ²½ν•  μ‹€μˆ˜ κ°’)

μœ„μ ―μ˜ ν…μŠ€νŠΈλ₯Ό 주어진 λ¬Έμžμ—΄λ‘œ λ³€κ²½ν•΄μš”. (λ³€κ²½ν•  λ¬Έμžμ—΄)

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
button:SetText("Hello World!")

μœ„μ ―μ— μ„€μ •λœ ν…μŠ€νŠΈλ₯Ό 얻을 수 μžˆμ–΄μš”.

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
print(button:GetText())

ν…μŠ€νŠΈμ˜ 색을 μ„€μ •ν•  수 μžˆμ–΄μš”. (λ³€κ²½ν•  Color κ°’)

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
button:SetTextColor(Color.new(0, 255, 0, 255))

ν…μŠ€νŠΈμ˜ 색을 κ°€μ Έμ˜¬ 수 μžˆμ–΄μš”.

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
print(button:GetTextColor())

λ²„νŠΌ μœ„μ ―μ˜ λ°°κ²½ 색을 μ„€μ •ν•  수 μžˆμ–΄μš”. (λ³€κ²½ν•  색)

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
button:SetBackgroundColor(Color.new(0, 255, 0, 255))

λ²„νŠΌ μœ„μ ―μ˜ λ°°κ²½ 색을 μ–»μ–΄μ˜¬ 수 μžˆμ–΄μš”.

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
print(button:GetBackgroundColor())

λ²„νŠΌ μœ„μ ―μ˜ Hover 색을 μ„€μ •ν•  수 μžˆμ–΄μš”. (λ³€κ²½ν•  색)

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
button:SetButtonHoverColor(Color.new(0, 255, 0, 255))

λ²„νŠΌ μœ„μ ―μ˜ Hover 색을 κ°€μ Έμ˜¬ 수 μžˆμ–΄μš”.

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
print(button:GetButtonHoverColor())

λ²„νŠΌ μœ„μ ―μ˜ Press 색을 μ„€μ •ν•  수 μžˆμ–΄μš”. (λ³€κ²½ν•  색)

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
button:SetButtonPressColor(Color.new(0, 255, 0, 255))

λ²„νŠΌ μœ„μ ―μ˜ Press 색을 κ°€μ Έμ˜¬ 수 μžˆμ–΄μš”.

-- μƒ˜ν”Œ --

local button = Workspace.ScreenUI.Button
print(button:GetButtonPressColor())

μ‚¬μš© κ°€λŠ₯ν•œ λΆ€λͺ¨ 였브젝트 κΈ°λŠ₯λ“€

속성

이벀트

ν•¨μˆ˜

Last updated