Engine Class
PluginGui
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
BindToClose(function: function):() |
เหตุการณ์
PluginDragDropped(dragData: Dictionary):RBXScriptSignal |
PluginDragEntered(dragData: Dictionary):RBXScriptSignal |
PluginDragLeft(dragData: Dictionary):RBXScriptSignal |
PluginDragMoved(dragData: Dictionary):RBXScriptSignal |
สมาชิกที่ได้รับทอด
สมาชิก 4 คนที่รับทอดมาจาก LayerCollector
สมาชิก 12 คนที่รับทอดมาจาก GuiBase2d
สมาชิก 57 คนที่รับทอดมาจาก Instance
สมาชิก 6 คนที่รับทอดมาจาก Object
ได้รับทอดโดย
เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
วิธีการ
BindToClose
GetRelativeMousePosition
ส่งค่ากลับ
ตัวอย่างโค้ด
PluginGui:GetRelativeMousePosition
local RunService = game:GetService("RunService")
local widgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
true,
false, -- สถานะเปิดใช้งาน, แทนที่
200,
300, -- ขนาด
150,
150 -- ขนาดขั้นต่ำ
)
local testWidget = plugin:CreateDockWidgetPluginGuiAsync("TestWidget", widgetInfo)
function update()
local v2 = testWidget:GetRelativeMousePosition()
testWidget.Title = ("(%d, %d)"):format(v2.x, v2.y)
end
RunService.Stepped:Connect(update)
update()เหตุการณ์
PluginDragDropped
พารามิเตอร์
ตัวอย่างโค้ด
ปลั๊กอินลากและวาง
assert(plugin, "สคริปต์นี้ต้องรันเป็น Studio plugin")
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 300, 200)
local dragSourceWidget = plugin:CreateDockWidgetPluginGuiAsync("แหล่งที่มาสำหรับการลาก", widgetInfo)
dragSourceWidget.Title = "แหล่งที่มาสำหรับการลาก"
local textBox = Instance.new("TextBox")
textBox.Parent = dragSourceWidget
textBox.Size = UDim2.new(1, 0, 0, 32)
textBox.Text = "สวัสดี, การลาก plugin"
local dragButton = Instance.new("TextButton")
dragButton.Size = UDim2.new(1, 0, 1, -32)
dragButton.Position = UDim2.new(0, 0, 0, 32)
dragButton.Text = "แก้ไขข้อความด้านบน จากนั้นเริ่มลากที่นี่"
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)
-- วิดเจ็ตนี้จะรับการดรอป
local dragTargetWidget = plugin:CreateDockWidgetPluginGuiAsync("เป้าหมายการดรอป", widgetInfo)
dragTargetWidget.Title = "เป้าหมายการดรอป"
-- TextLabel นี้จะแสดงสิ่งที่ถูกดรอป
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.Text = "ดรอปที่นี่..."
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
พารามิเตอร์
ตัวอย่างโค้ด
ปลั๊กอินลากและวาง
assert(plugin, "สคริปต์นี้ต้องรันเป็น Studio plugin")
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 300, 200)
local dragSourceWidget = plugin:CreateDockWidgetPluginGuiAsync("แหล่งที่มาสำหรับการลาก", widgetInfo)
dragSourceWidget.Title = "แหล่งที่มาสำหรับการลาก"
local textBox = Instance.new("TextBox")
textBox.Parent = dragSourceWidget
textBox.Size = UDim2.new(1, 0, 0, 32)
textBox.Text = "สวัสดี, การลาก plugin"
local dragButton = Instance.new("TextButton")
dragButton.Size = UDim2.new(1, 0, 1, -32)
dragButton.Position = UDim2.new(0, 0, 0, 32)
dragButton.Text = "แก้ไขข้อความด้านบน จากนั้นเริ่มลากที่นี่"
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)
-- วิดเจ็ตนี้จะรับการดรอป
local dragTargetWidget = plugin:CreateDockWidgetPluginGuiAsync("เป้าหมายการดรอป", widgetInfo)
dragTargetWidget.Title = "เป้าหมายการดรอป"
-- TextLabel นี้จะแสดงสิ่งที่ถูกดรอป
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.Text = "ดรอปที่นี่..."
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
พารามิเตอร์
ตัวอย่างโค้ด
ปลั๊กอินลากและวาง
assert(plugin, "สคริปต์นี้ต้องรันเป็น Studio plugin")
local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 300, 200)
local dragSourceWidget = plugin:CreateDockWidgetPluginGuiAsync("แหล่งที่มาสำหรับการลาก", widgetInfo)
dragSourceWidget.Title = "แหล่งที่มาสำหรับการลาก"
local textBox = Instance.new("TextBox")
textBox.Parent = dragSourceWidget
textBox.Size = UDim2.new(1, 0, 0, 32)
textBox.Text = "สวัสดี, การลาก plugin"
local dragButton = Instance.new("TextButton")
dragButton.Size = UDim2.new(1, 0, 1, -32)
dragButton.Position = UDim2.new(0, 0, 0, 32)
dragButton.Text = "แก้ไขข้อความด้านบน จากนั้นเริ่มลากที่นี่"
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)
-- วิดเจ็ตนี้จะรับการดรอป
local dragTargetWidget = plugin:CreateDockWidgetPluginGuiAsync("เป้าหมายการดรอป", widgetInfo)
dragTargetWidget.Title = "เป้าหมายการดรอป"
-- TextLabel นี้จะแสดงสิ่งที่ถูกดรอป
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.Text = "ดรอปที่นี่..."
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
WindowFocused
ตัวอย่างโค้ด
การตรวจจับสถานะโฟกัสของ PluginGui
local info = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 200, 50, 1, 1)
local widget = plugin:CreateDockWidgetPluginGuiAsync("TestWidget", info)
local function onFocusReleased()
widget.Title = "ฉันไม่ได้อยู่ในโฟกัส :("
end
local function onFocused()
widget.Title = "ฉันอยู่ในโฟกัส :D"
end
widget.WindowFocusReleased:Connect(onFocusReleased)
widget.WindowFocused:Connect(onFocused)WindowFocusReleased
ตัวอย่างโค้ด
การตรวจจับสถานะโฟกัสของ PluginGui
local info = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 200, 50, 1, 1)
local widget = plugin:CreateDockWidgetPluginGuiAsync("TestWidget", info)
local function onFocusReleased()
widget.Title = "ฉันไม่ได้อยู่ในโฟกัส :("
end
local function onFocused()
widget.Title = "ฉันอยู่ในโฟกัส :D"
end
widget.WindowFocusReleased:Connect(onFocusReleased)
widget.WindowFocused:Connect(onFocused)