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?