Button

Button

ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉ๋˜๋Š” Widget Button ๊ฐ์ฒด.

์ด๋ฒคํŠธ

OnPressEvent

๋ฒ„ํŠผ์ด ๋ˆŒ๋ฆด ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์—์š”. ์—ฐ๊ฒฐํ•จ์ˆ˜ ํ˜•์‹์€ function(pressButton), pressButton ๋Š” ๋ˆŒ๋ฆฐ ์œ„์ ฏ๋ฒ„ํŠผ ๊ฐ์ฒด ์ž…๋‹ˆ๋‹ค.

-- ์ƒ˜ํ”Œ --

local button = Workspace.ScreenUI.Button

local function PressEvent(self) --OnPressEvent๋กœ ์—ฐ๊ฒฐ๋œ ํ•จ์ˆ˜๋Š” self ์ธ์ž๊ฐ€ ๊ณ ์ •์ ์œผ๋กœ ๋“ค์–ด๊ฐ€์š”.
    print(self.Name .. " Button Click!")
end
button.OnPressEvent:Connect(PressEvent) --๋ฒ„ํŠผ์— ํ•ด๋‹น ๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ์„๋•Œ ํ˜ธ์ถœ๋˜๋Š” ํ•จ์ˆ˜๋ฅผ ์—ฐ๊ฒฐํ•ด์š”.

OnUpEvent

๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ๋‹ค๊ฐ€ ๋–ผ์–ด์งˆ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์—์š”. ์—ฐ๊ฒฐํ•จ์ˆ˜ ํ˜•์‹์€ function(upButton), upButton ๋Š” ๋ˆŒ๋ ธ๋‹ค๊ฐ€ ๋–ผ์–ด์ง„ ์œ„์ ฏ๋ฒ„ํŠผ ๊ฐ์ฒด ์ž…๋‹ˆ๋‹ค.

-- ์ƒ˜ํ”Œ --

local button = Workspace.ScreenUI.Button

local function UpEvent(self) --OnUpEvent๋กœ ์—ฐ๊ฒฐ๋œ ํ•จ์ˆ˜๋Š” self ์ธ์ž๊ฐ€ ๊ณ ์ •์ ์œผ๋กœ ๋“ค์–ด๊ฐ€์š”.
    print(self.Name .. " Button Click!")
end
button.OnUpEvent:Connect(UpEvent) --๋ฒ„ํŠผ์— ํ•ด๋‹น ๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ๋‹ค๊ฐ€ ๋–ผ์–ด์งˆ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ํ•จ์ˆ˜๋ฅผ ์—ฐ๊ฒฐํ•ด์š”.

์†์„ฑ

ImageDrawType

๋ฒ„ํŠผ ์ด๋ฏธ์ง€์˜ DrawType์„ ์„ค์ •ํ•˜๊ณ  ์–ป์„ ์ˆ˜ ์žˆ์–ด์š” (None, Tile, Slice, Border).

-- ์ƒ˜ํ”Œ --

local button = Workspace.ScreenUI.Button

button.ImageDrawType = Enum.ImageDrawType.Image

ImageSliceLeftRight

๋ฒ„ํŠผ ์ด๋ฏธ์ง€์˜ 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 : ์šฐ

ImageSliceTopBottm

๋ฒ„ํŠผ ์ด๋ฏธ์ง€์˜ 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 : ํ•˜

ImageTiling

๋ฒ„ํŠผ ์ด๋ฏธ์ง€์˜ DrawType์ด Tile์ผ ๋•Œ์˜ ์˜ต์…˜๊ฐ’์„ ์„ค์ •ํ•˜๊ณ  ์–ป์„ ์ˆ˜ ์žˆ์–ด์š” (NoTile, Horizontal, Vertical, Both)

-- ์ƒ˜ํ”Œ --

local button = Workspace.ScreenUI.Button

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

ํ•จ์ˆ˜

void SetText(number Value)

(X.0 , X) ๊ฐ’์€ ๋ชจ๋‘ X๋กœ ๋ฐ˜ํ™˜๋˜์„œ ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค. X.0์„ ์ถœ๋ ฅํ•˜๊ณ  ์‹ถ์œผ๋ฉด tostring์œผ๋กœ ๋ณ€ํ™˜ํ›„ ์ด์šฉํ•ด์ฃผ์„ธ์š” ์œ„์ ฏ์˜ ํ…์ŠคํŠธ๋ฅผ ์ฃผ์–ด์ง„ ์‹ค์ˆ˜๋กœ ๋ณ€๊ฒฝํ•ด์š”. ( ๋ณ€๊ฒฝํ•  ์‹ค์ˆ˜ ๊ฐ’)

void SetText(string InText)

์œ„์ ฏ์˜ ํ…์ŠคํŠธ๋ฅผ ์ฃผ์–ด์ง„ ๋ฌธ์ž์—ด๋กœ ๋ณ€๊ฒฝํ•ด์š”. (๋ณ€๊ฒฝํ•  ๋ฌธ์ž์—ด)

-- ์ƒ˜ํ”Œ --

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

string GetText()

์œ„์ ฏ์— ์„ค์ •๋œ ํ…์ŠคํŠธ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์–ด์š”.

-- ์ƒ˜ํ”Œ --

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

void SetTextColor(Color color)

ํ…์ŠคํŠธ์˜ ์ƒ‰์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (๋ณ€๊ฒฝํ•  Color ๊ฐ’)

-- ์ƒ˜ํ”Œ --

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

Color GetTextColor()

ํ…์ŠคํŠธ์˜ ์ƒ‰์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์–ด์š”.

-- ์ƒ˜ํ”Œ --

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

void SetBackgroundColor(Color color)

๋ฒ„ํŠผ ์œ„์ ฏ์˜ ๋ฐฐ๊ฒฝ ์ƒ‰์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (๋ณ€๊ฒฝํ•  ์ƒ‰)

-- ์ƒ˜ํ”Œ --

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

Color GetBackgroundColor()

๋ฒ„ํŠผ ์œ„์ ฏ์˜ ๋ฐฐ๊ฒฝ ์ƒ‰์„ ์–ป์–ด์˜ฌ ์ˆ˜ ์žˆ์–ด์š”.

-- ์ƒ˜ํ”Œ --

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

void SetButtonHoverColor(Color color)

๋ฒ„ํŠผ ์œ„์ ฏ์˜ Hover ์ƒ‰์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (๋ณ€๊ฒฝํ•  ์ƒ‰)

-- ์ƒ˜ํ”Œ --

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

Color GetButtonHoverColor()

๋ฒ„ํŠผ ์œ„์ ฏ์˜ Hover ์ƒ‰์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์–ด์š”.

-- ์ƒ˜ํ”Œ --

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

void SetButtonPressColor(Color color)

๋ฒ„ํŠผ ์œ„์ ฏ์˜ Press ์ƒ‰์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (๋ณ€๊ฒฝํ•  ์ƒ‰)

-- ์ƒ˜ํ”Œ --

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

Color GetButtonPressColor()

๋ฒ„ํŠผ ์œ„์ ฏ์˜ Press ์ƒ‰์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์–ด์š”.

-- ์ƒ˜ํ”Œ --

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

์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ถ€๋ชจ ์˜ค๋ธŒ์ ํŠธ ๊ธฐ๋Šฅ๋“ค

์†์„ฑ

์ด๋ฆ„

์„ค๋ช…

์œ„์ ฏ์˜ ์œ„์น˜๋ฅผ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์–ด์š”. (X์ขŒํ‘œ ๊ฐ’, Y์ขŒํ‘œ ๊ฐ’, 0)

์œ„์ ฏ์˜ ํšŒ์ „์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (์„ค์ •ํ•  ๊ฐ’)

์œ„์ ฏ์˜ ์Šค์ผ€์ผ์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (์„ค์ •ํ•  ๊ฐ’)

์œ„์ ฏ์˜ ํฌ๊ธฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (๊ฐ€๋กœ๊ฐ’, ์„ธ๋กœ๊ฐ’, 0)

์œ„์ ฏ์˜ ๊ทธ๋ฆฌ๋Š” ์ˆœ์„œ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”.

UI ์œ„์ ฏ์˜ ํ‘œ์‹œ ์—ฌ๋ถ€๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (์œ„์ ฏ ํ‘œ์‹œ ์—ฌ๋ถ€)

UI ์œ„์ ฏ์˜ ๋ฐ˜์‘ ์—ฌ๋ถ€๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (์œ„์ ฏ ๋ฐ˜์‘ ์—ฌ๋ถ€)

์œ„์ ฏ์˜ ํˆฌ๋ช… ๊ฐ’์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (์„ค์ •ํ•  ๊ฐ’)

์œ„์ ฏ์˜ ๊ณ ์ • ์—ฌ๋ถ€๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (์„ค์ •ํ•  ํƒ€์ž…)

์œ„์ ฏ์˜ ์ฑ„์šฐ๊ธฐ๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”.

์ด๋ฒคํŠธ

์ด๋ฆ„

์„ค๋ช…

widget์ด ๋ณด์—ฌ์งˆ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์—์š”. ์—ฐ๊ฒฐํ•จ์ˆ˜ ํ˜•์‹์€ function(widget), widget ์€ ๋ณด์—ฌ์ง€๋Š” widget ๊ฐ์ฒด ์ž…๋‹ˆ๋‹ค.

widget์ด ์•ˆ ๋ณด์—ฌ์งˆ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์—์š”. ์—ฐ๊ฒฐํ•จ์ˆ˜ ํ˜•์‹์€ function(widget), widget ์€ ์•ˆ ๋ณด์—ฌ์ง€๋Š” widget ๊ฐ์ฒด ์ž…๋‹ˆ๋‹ค.

widget์˜ ๋“œ๋ž˜๊ทธ๊ฐ€ ์‹œ์ž‘ ๋  ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์—์š”. ์—ฐ๊ฒฐํ•จ์ˆ˜ ํ˜•์‹์€ function(widget, vector2D), widget์€ ํด๋ฆญํ•œ ๊ฐ์ฒด, vector2D๋Š” ๋งˆ์šฐ์Šค ์œ„์น˜์—์š”.

widget์˜ ๋“œ๋ž˜๊ทธ๊ฐ€ ์ทจ์†Œ๋  ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์—์š”. ์—ฐ๊ฒฐํ•จ์ˆ˜ ํ˜•์‹์€ function(widget, vector2D), widget์€ ํด๋ฆญํ•œ ๊ฐ์ฒด, vector2D๋Š” ๋งˆ์šฐ์Šค ์œ„์น˜์—์š”.

widget์˜ ๋“œ๋ž˜๊ทธ๊ฐ€ ๋“œ๋ž๋  ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ์ด๋ฒคํŠธ์—์š”. ์—ฐ๊ฒฐํ•จ์ˆ˜ ํ˜•์‹์€ function(widget, vector2D, dragwidget), widget์€ ๋“œ๋žํ•œ ๊ฐ์ฒด, vector2D๋Š” ๋งˆ์šฐ์Šค ์œ„์น˜, dragwidget๋Š” ๋“œ๋ž˜๊ทธํ•œ widget์—์š”.

ํ•จ์ˆ˜

์ด๋ฆ„

์„ค๋ช…

(deprecate) AddChildUIWidget ํ•จ์ˆ˜๋กœ ์ด์šฉํ•˜์„ธ์š”.

์ž์‹ UI ์œ„์ ฏ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์–ด์š”. (์ž์‹์œผ๋กœ ์ถ”๊ฐ€ํ•  UI ์œ„์ ฏ)

๋ถ€๋ชจ UI ์œ„์ ฏ์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด์š”. (๋ถ€๋ชจ๋กœ ์„ค์ •ํ•  UI ์œ„์ ฏ)

์œ„์ ฏ์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์–ด์š”.

์œ„์ ฏ์˜ ํƒ€์ž…์„ ๋ฌธ์ž์—ด๋กœ ์–ป์„ ์ˆ˜ ์žˆ์–ด์š”.

์œ„์ ฏ์˜ ํƒ€์ž…์„ Enum ํ˜•์‹์œผ๋กœ ์–ป์„ ์ˆ˜ ์žˆ์–ด์š”.

์œ„์ ฏ์˜ DragEvent ๋ฐœ์ƒ ์‹œ ๋ณต์‚ฌ๋˜์–ด ๋ณด์—ฌ์งˆ widget์„ ์„ธํŒ…ํ•ด์š”.

์œ„์ ฏ์˜ DragWidget์— ์ ์šฉ๋  Offset ์ด์—์š”.

Last updated

Was this helpful?