PluginGui

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

만들 수 없음
복제되지 않음

PluginGui는 다양한 Roblox Studio 위젯에서 GuiObjects 표시를 허용하는 GUI의 추상 클래스입니다.현재로서는 유일한 PluginGui 유형은 DockWidgetPluginGui 이지만 미래에 더 많이 있을 수 있습니다!

요약

속성

속성LayerCollector에서 상속되었습니다속성GuiBase2d에서 상속되었습니다

메서드

이벤트

이벤트GuiBase2d에서 상속되었습니다

속성

Title

병렬 읽기

콘텐츠 위에 표시되는 타이틀입니다. 기본값은 빈 문자열입니다.

메서드

BindToClose

()

이 함수는 기본 동작을 재정의하여 함수를 PluginGui 닫기 버튼에 바인딩합니다.

기본적으로 사용자가 오른쪽 상단의 'x' 버튼을 클릭하면 PluginGui 속성의 Enabled 속성이 false로 설정되어 창이 닫힙니다.사용자가 정말로 창을 닫거나 작업을 저장하기를 원하는지 확인할 수 있도록 사용자 지정 함수가 BindToClose를 사용하여 바인딩되면 이 동작이 재정의되어 창을 닫거나 작업을 저장할 수 있는 기회를 제공합니다.

기본 닫기 동작이 이 함수에 의해 재정의되므로 기본값으로 닫기를 수동으로 설정하려면 PluginGuiPluginGui.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()

참조하세요:

매개 변수

function: function

닫기 버튼에 바인딩할 함수. 함수가 지정되지 않으면 이전에 지정된 함수가 해제됩니다.

기본값: "nil"

반환

()

GetRelativeMousePosition

플러그인 보안

GetRelativeMousePosition는 마우스의 위치를 가져와 왼쪽 상단 모서리의 PluginGui에 관련하여 반환합니다.반환된 값은 PluginGui에 마우스 입력이 시작되었거나 현재 창에 마우스가 호버하고 있는 경우에만 변경됩니다.


반환

마우스의 화면 위치가 PluginGui에 대해 픽셀로.

코드 샘플

PluginGui:GetRelativeMousePosition

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() 에 의해 시작됩니다.

참조하세요:

매개 변수

dragData: Dictionary

코드 샘플

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".

Plugin Drag and Drop

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 발사되면 숨겨져야 합니다.

참조하세요:

매개 변수

dragData: Dictionary

원래 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".

Plugin Drag and Drop

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).

참조하세요:

매개 변수

dragData: Dictionary

원래 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".

Plugin Drag and Drop

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 는 사용자의 마우스가 에서 드래그 작업을 시작한 동안 이동하면 발생합니다.

참조하세요:

매개 변수

dragData: Dictionary

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.

Detecting PluginGui Focus State

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.

Detecting PluginGui Focus State

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)