PluginGui는 다양한 Roblox Studio 위젯에서 GuiObjects 표시를 허용하는 GUI의 추상 클래스입니다.현재로서는 유일한 PluginGui 유형은 DockWidgetPluginGui 이지만 미래에 더 많이 있을 수 있습니다!
요약
속성
콘텐츠 위에 표시되는 타이틀입니다. PluginGui .
이 LayerCollector 의 표시 여부를 전환합니다.
플레이어의 캐릭터가 재생성될 때마다 리셋(자체를 삭제하고 플레이어의 캐릭터로 다시 클론화)되는지 여부를 결정합니다.
이 GuiObject.ZIndex 의 모든 하위에서 어떻게 작동하는지 제어합니다. LayerCollector .
픽셀로 표시되는 실제 화면 위치의 GuiBase2d 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소 요소
GuiBase2d 요소의 실제 화면 회전을 도 단위로 설명합니다.
픽셀로 표시되는 실제 화면 크기의 GuiBase2d 요소를 설명합니다.
true 로 설정되면 지역화가 이 GuiBase2d 및 그 하위에 적용됩니다.
이 GuiBase2d 및 그 하위에 자동화된 로캘리제이션을 적용하기 위해 사용할 LocalizationTable 참조.
아래쪽 방향으로 게임패드 선택 행동을 사용자 지정합니다.
왼쪽 방향에서 게임패드 선택 동작을 사용자 지정합니다.
오른쪽 방향으로 게임패드 선택 행동을 사용자 지정합니다.
위쪽으로 게임패드 선택 행동을 사용자 지정합니다.
게임패드 선택 이동을 사용자 지정할 수 있습니다.
메서드
기능을 PluginGui 닫기 버튼에 바인딩하여 기본 동작을 재정의합니다.
플러그인GUI에 대한 마우스 위치를 반환합니다.
이벤트
사용자가 플러그인GUI 위에서 마우스를 놓을 때 드래그 작업을 시작하는 Plugin:StartDrag()에 의해 발생하는 경우 화재
사용자의 마우스가 Plugin:StartDrag().
사용자의 마우스가 Plugin:StartDrag()에 의해 시작된 드래그 작업 중에 PluginGui를 떠날 때 발생합니다.
사용자의 마우스가 Plugin:StartDrag()에 의해 시작된 드래그 작업 중에 PluginGui 내에서 이동하면 발생합니다.
사용자가 PluginGui의 창과 상호작용을 중지하면 발생합니다.
사용자가 PluginGui의 창과 상호작용을 시작할 때 발생합니다.
- SelectionChanged(amISelected : boolean,previousSelection : GuiObject,newSelection : GuiObject):RBXScriptSignal
연결된 게임패드 선택이 이동하거나, 나가거나, 변경되면 발생합니다. GuiBase2d 또는 모든 하위 요소에서 GuiObjects 입니다.
속성
메서드
BindToClose
이 함수는 기본 동작을 재정의하여 함수를 PluginGui 닫기 버튼에 바인딩합니다.
기본적으로 사용자가 오른쪽 상단의 'x' 버튼을 클릭하면 PluginGui 속성의 Enabled 속성이 false로 설정되어 창이 닫힙니다.사용자가 정말로 창을 닫거나 작업을 저장하기를 원하는지 확인할 수 있도록 사용자 지정 함수가 BindToClose를 사용하여 바인딩되면 이 동작이 재정의되어 창을 닫거나 작업을 저장할 수 있는 기회를 제공합니다.
기본 닫기 동작이 이 함수에 의해 재정의되므로 기본값으로 닫기를 수동으로 설정하려면 PluginGui 를 PluginGui.Enabled 로 설정해야 합니다.As the default closing behavior is overwritten by this function, you'll need to configure the to close manually by setting to false .예를 들어, 아래 스니펫에서 사용자는 GUI를 닫기 위해 확인 버튼을 클릭해야 합니다.
local closing = false
pluginGui:BindToClose(function()
-- 버튼을 이미 만들지 않았는지 확인
if closing then
return
end
closing = true
-- 확인 버튼 생성
local confirmButton = Instance.new("TextButton")
confirmButton.AnchorPoint = Vector2.new(0.5, 0.5)
confirmButton.Size = UDim2.new(0.5, 0, 0.5, 0)
confirmButton.Position = UDim2.new(0.5, 0, 0.5, 0)
confirmButton.BackgroundColor3 = Color3.new(1, 0, 0)
confirmButton.Text = "Close?"
confirmButton.Parent = pluginGui
-- 클릭 감지 listen for click
confirmButton.Activated:Connect(function()
-- gui 닫기
pluginGui.Enabled = false
-- 제거 확인 버튼 제거
confirmButton:Destroy()
end)
end)
BindToClose에 인수를 사용하지 않고 '해제'하고 위에 설명된 기본 동작으로 되돌릴 수 있습니다. 예를 들어:
pluginGui:BindToClose()
참조하세요:
- DataModel:BindToClose() , 함수를 게임 종료에 바인딩하는 데 사용할 수 있으며 이 함수와 혼동되어서는 안됩니다
매개 변수
닫기 버튼에 바인딩할 함수. 함수가 지정되지 않으면 이전에 지정된 함수가 해제됩니다.
반환
GetRelativeMousePosition
GetRelativeMousePosition는 마우스의 위치를 가져와 왼쪽 상단 모서리의 PluginGui에 관련하여 반환합니다.반환된 값은 PluginGui에 마우스 입력이 시작되었거나 현재 창에 마우스가 호버하고 있는 경우에만 변경됩니다.
반환
마우스의 화면 위치가 PluginGui에 대해 픽셀로.
코드 샘플
local RunService = game:GetService("RunService")
local widgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
true,
false, -- Enabled state, override
200,
300, -- Size
150,
150 -- Minimum size
)
local testWidget = plugin:CreateDockWidgetPluginGui("TestWidget", widgetInfo)
function update()
local v2 = testWidget:GetRelativeMousePosition()
testWidget.Title = ("(%d, %d)"):format(v2.x, v2.y)
end
RunService.Stepped:Connect(update)
update()
이벤트
PluginDragDropped
플러그인드래그드롭 는 사용자가 마우스를 놓은 동안 시작된 드래그 작업 중에 PluginGui 에서 발생하며, 해당 작업은 Plugin:StartDrag() 에 의해 시작됩니다.
참조하세요:
매개 변수
코드 샘플
This code sample creates two plugin widget windows: a drag source and a drop target. In the source window, the script creates a TextBox and TextButton to allow the user to begin a plugin drag action. The drop target window will display the MimeType of whatever is dragged into it using a TextLabel. If the MimeType is text/plain, it will display the plain text data instead.
To run this code sample as a plugin, paste it into a Script. Then, right-click the script in the Explorer window and choose "Save as Local Plugin".
assert(plugin, "This script must be run as a Studio plugin")
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 300, 200)
local dragSourceWidget = plugin:CreateDockWidgetPluginGui("Drag Source", widgetInfo)
dragSourceWidget.Title = "Drag Source"
local textBox = Instance.new("TextBox")
textBox.Parent = dragSourceWidget
textBox.Size = UDim2.new(1, 0, 0, 32)
textBox.Text = "Hello, plugin drags"
local dragButton = Instance.new("TextButton")
dragButton.Size = UDim2.new(1, 0, 1, -32)
dragButton.Position = UDim2.new(0, 0, 0, 32)
dragButton.Text = "Edit the text above, then start drag here"
dragButton.Parent = dragSourceWidget
function onMouseButton1Down()
local dragData = {
Sender = "SomeDragSource",
MimeType = "text/plain",
Data = textBox.Text,
MouseIcon = "",
DragIcon = "",
HotSpot = Vector2.new(0, 0),
}
plugin:StartDrag(dragData)
end
dragButton.MouseButton1Down:Connect(onMouseButton1Down)
-- This widget will receive drops
local dragTargetWidget = plugin:CreateDockWidgetPluginGui("Drop Target", widgetInfo)
dragTargetWidget.Title = "Drop Target"
-- This TextLabel will display what was dropped
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.Text = "Drop here..."
textLabel.Parent = dragTargetWidget
local function onDragDrop(dragData)
if dragData.MimeType == "text/plain" then
textLabel.Text = dragData.Data
else
textLabel.Text = dragData.MimeType
end
end
dragTargetWidget.PluginDragDropped:Connect(onDragDrop)
dragTargetWidget.PluginDragEntered:Connect(function(_dragData)
print("PluginDragEntered")
end)
dragTargetWidget.PluginDragLeft:Connect(function(_dragData)
print("PluginDragLeft")
end)
dragTargetWidget.PluginDragMoved:Connect(function(_dragData)
print("PluginDragMoved")
end)
PluginDragEntered
PluginDragEntered 는 사용자의 마우스가 드래그 작업을 시작하는 동안 들어가면 발생합니다.
이 이벤트는 드래그 작업을 놓을 수 있는 PluginGuis에 "여기에 드롭" UI를 표시하는 데 유용합니다.그러한 UI는 발사할 때 PluginDragLeft 또는 PluginDragDropped 발사되면 숨겨져야 합니다.
참조하세요:
매개 변수
원래 Plugin:StartDrag() 전달된 데이터의 복사본.
코드 샘플
This code sample creates two plugin widget windows: a drag source and a drop target. In the source window, the script creates a TextBox and TextButton to allow the user to begin a plugin drag action. The drop target window will display the MimeType of whatever is dragged into it using a TextLabel. If the MimeType is text/plain, it will display the plain text data instead.
To run this code sample as a plugin, paste it into a Script. Then, right-click the script in the Explorer window and choose "Save as Local Plugin".
assert(plugin, "This script must be run as a Studio plugin")
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 300, 200)
local dragSourceWidget = plugin:CreateDockWidgetPluginGui("Drag Source", widgetInfo)
dragSourceWidget.Title = "Drag Source"
local textBox = Instance.new("TextBox")
textBox.Parent = dragSourceWidget
textBox.Size = UDim2.new(1, 0, 0, 32)
textBox.Text = "Hello, plugin drags"
local dragButton = Instance.new("TextButton")
dragButton.Size = UDim2.new(1, 0, 1, -32)
dragButton.Position = UDim2.new(0, 0, 0, 32)
dragButton.Text = "Edit the text above, then start drag here"
dragButton.Parent = dragSourceWidget
function onMouseButton1Down()
local dragData = {
Sender = "SomeDragSource",
MimeType = "text/plain",
Data = textBox.Text,
MouseIcon = "",
DragIcon = "",
HotSpot = Vector2.new(0, 0),
}
plugin:StartDrag(dragData)
end
dragButton.MouseButton1Down:Connect(onMouseButton1Down)
-- This widget will receive drops
local dragTargetWidget = plugin:CreateDockWidgetPluginGui("Drop Target", widgetInfo)
dragTargetWidget.Title = "Drop Target"
-- This TextLabel will display what was dropped
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.Text = "Drop here..."
textLabel.Parent = dragTargetWidget
local function onDragDrop(dragData)
if dragData.MimeType == "text/plain" then
textLabel.Text = dragData.Data
else
textLabel.Text = dragData.MimeType
end
end
dragTargetWidget.PluginDragDropped:Connect(onDragDrop)
dragTargetWidget.PluginDragEntered:Connect(function(_dragData)
print("PluginDragEntered")
end)
dragTargetWidget.PluginDragLeft:Connect(function(_dragData)
print("PluginDragLeft")
end)
dragTargetWidget.PluginDragMoved:Connect(function(_dragData)
print("PluginDragMoved")
end)
PluginDragLeft
PluginDragLeft 는 사용자의 마우스가 드래그 작업을 시작한 동안 떠났을 때 발생합니다.
이 이벤트와 PluginDragDropped는 드래그 작업을 놓을 수 있는 PluginGuis에서 "여기에 드롭" UI를 숨기는 데 유용합니다.이러한 UI는 발사될 때 나타나야 합니다(PluginDragEntered).
참조하세요:
매개 변수
원래 Plugin:StartDrag() 전달된 데이터의 복사본.
코드 샘플
This code sample creates two plugin widget windows: a drag source and a drop target. In the source window, the script creates a TextBox and TextButton to allow the user to begin a plugin drag action. The drop target window will display the MimeType of whatever is dragged into it using a TextLabel. If the MimeType is text/plain, it will display the plain text data instead.
To run this code sample as a plugin, paste it into a Script. Then, right-click the script in the Explorer window and choose "Save as Local Plugin".
assert(plugin, "This script must be run as a Studio plugin")
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 300, 200)
local dragSourceWidget = plugin:CreateDockWidgetPluginGui("Drag Source", widgetInfo)
dragSourceWidget.Title = "Drag Source"
local textBox = Instance.new("TextBox")
textBox.Parent = dragSourceWidget
textBox.Size = UDim2.new(1, 0, 0, 32)
textBox.Text = "Hello, plugin drags"
local dragButton = Instance.new("TextButton")
dragButton.Size = UDim2.new(1, 0, 1, -32)
dragButton.Position = UDim2.new(0, 0, 0, 32)
dragButton.Text = "Edit the text above, then start drag here"
dragButton.Parent = dragSourceWidget
function onMouseButton1Down()
local dragData = {
Sender = "SomeDragSource",
MimeType = "text/plain",
Data = textBox.Text,
MouseIcon = "",
DragIcon = "",
HotSpot = Vector2.new(0, 0),
}
plugin:StartDrag(dragData)
end
dragButton.MouseButton1Down:Connect(onMouseButton1Down)
-- This widget will receive drops
local dragTargetWidget = plugin:CreateDockWidgetPluginGui("Drop Target", widgetInfo)
dragTargetWidget.Title = "Drop Target"
-- This TextLabel will display what was dropped
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.Text = "Drop here..."
textLabel.Parent = dragTargetWidget
local function onDragDrop(dragData)
if dragData.MimeType == "text/plain" then
textLabel.Text = dragData.Data
else
textLabel.Text = dragData.MimeType
end
end
dragTargetWidget.PluginDragDropped:Connect(onDragDrop)
dragTargetWidget.PluginDragEntered:Connect(function(_dragData)
print("PluginDragEntered")
end)
dragTargetWidget.PluginDragLeft:Connect(function(_dragData)
print("PluginDragLeft")
end)
dragTargetWidget.PluginDragMoved:Connect(function(_dragData)
print("PluginDragMoved")
end)
PluginDragMoved
PluginDragMoved 는 사용자의 마우스가 에서 드래그 작업을 시작한 동안 이동하면 발생합니다.
참조하세요:
매개 변수
WindowFocusReleased
WindowFocusReleased 는 사용자가 PluginGui의 창과 상호작용을 중지할 때 즉시 발생하며, 일반적으로 창에 없는 무언가를 클릭하여 발생합니다.이 함수는 유사하게 명명된 UserInputService.WindowFocusReleased 이벤트와 유사하게 작동합니다.
사용자가 이 플러그인 가이에 초점을 맞추고 있을 때 초점이 다른 PluginGui 로 이동하면 이 이벤트가 다른 이벤트 WindowFocused 보다 먼저 발생합니다.그러나 주 게임 창이 포커스에 있으면 이 이벤트가 후에 UserInputService.WindowFocused 발생합니다.
코드 샘플
This code sample demonstrates how the focus state of a PluginGui can be tracked using the WindowFocused() and WindowFocusReleased() events. It changes the Title() as the focus state changes.
local info = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 200, 50, 1, 1)
local widget = plugin:CreateDockWidgetPluginGui("TestWidget", info)
local function onFocusReleased()
widget.Title = "I'm not in focus :("
end
local function onFocused()
widget.Title = "I'm in focus :D"
end
widget.WindowFocusReleased:Connect(onFocusReleased)
widget.WindowFocused:Connect(onFocused)
WindowFocused
WindowFocused 는 사용자가 PluginGui의 창과 상호작용을 시작할 때 즉시 발생하며, 일반적으로 해당 창을 클릭하여 발생합니다.이 함수는 유사하게 명명된 UserInputService.WindowFocused 이벤트와 유사하게 작동합니다.마우스 버튼과 관련된 모든 GuiObject.InputBegan 이벤트가 발생하기 전에 발사됩니다.
다른 PluginGui 가 포커스에 있고 사용자가 이 PluginGui에 포커스를 맞추면 이 이벤트는 다른 이벤트의 WindowFocusReleased 이벤트 이후에 발생합니다.그러나 주 게임 창이 포커스에 있으면 이 이벤트는 후에 UserInputService.WindowFocusReleased 발생합니다.
코드 샘플
This code sample demonstrates how the focus state of a PluginGui can be tracked using the WindowFocused() and WindowFocusReleased() events. It changes the Title() as the focus state changes.
local info = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 200, 50, 1, 1)
local widget = plugin:CreateDockWidgetPluginGui("TestWidget", info)
local function onFocusReleased()
widget.Title = "I'm not in focus :("
end
local function onFocused()
widget.Title = "I'm in focus :D"
end
widget.WindowFocusReleased:Connect(onFocusReleased)
widget.WindowFocused:Connect(onFocused)