Plugin
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ปลั๊กอิน เป็นวัตถุหลักที่รับผิดชอบในการสร้างโครงสร้างพื้นฐานของ Studio ช่องเก็บของปลั๊กอิน ปุ่มปลั๊กอิน และอื
ตัวอย่างโค้ด
The plugin global reference is not passed to ModuleScripts within the plugin. In order to use it in a ModuleScript, you must explicitly pass it as seen in the example below.
assert(plugin, "This script must be run as a plugin!")
-- Code beyond this point will execute only if the script is run as a plugin
-- Load the module and pass the plugin reference
local pluginModule = require(script.Parent.PluginModule)
pluginModule:Initialize(plugin)
-- Verify if the plugin reference was initialized
pluginModule:CheckForPluginGlobal()
local pluginModule = {}
local plugin -- Local plugin reference
-- Initialize the plugin reference if not already set
function pluginModule:Initialize(pluginReference: Plugin)
if plugin ~= pluginReference then
plugin = pluginReference
else
error("Plugin is already initialized")
end
end
-- Check if the plugin reference is set and print out appropriate info
function pluginModule:CheckForPluginGlobal()
if plugin ~= nil then
print("Plugin reference is set!")
else
warn("Plugin reference is missing!")
end
end
return pluginModule
สรุป
คุณสมบัติ
กลับว่าผู้ใช้เปิดใช้งาน Collisions ในสตูดิโอในแท็บแบบ Model
กลับขนาดการจับตารางที่ผู้ใช้ตั้งใน Studio
วิธีการ
ตั้งค่าสถานะของปลั๊กอินโทรที่เรียกใช้เป็น "ใช้งาน"
- CreatePluginAction(actionId : string,text : string,statusTip : string,iconName : string,allowBinding : bool):PluginAction
สร้าง PluginAction ซึ่งเป็นวัตถุที่แทนที่การกระทําทั่วไปใน Roblox Studio โดยไม่มี Toolbar หรือ Enum.Button โดยตรง
สร้างเมนูปลั๊กอินใหม่
สร้าง PluginToolbar ใหม่ด้วยชื่อที่กำหนด
ปิดใช้งานปลั๊กอิน
กลับ Enum.JointCreationMode ที่ผู้ใช้ตั้งในสตูดิโอใต้แท็บ โมเดล
กลับไปที่ Mouse ที่สามารถใช้ได้ในขณะที่ปลั๊กอินอยู่ใช้งาน
กลับ Enum.RibbonTool ที่เลือกไว้ในขณะนี้
คีย์
กลับ true หากปุ่มนี้ถูกเปิดใช้งานอยู่ในขณะนี้หลังจากที่ได้ถูกเปิดใช้งานผ่านหน้าฟังก์ชัน Plugin:Activate()
กลับ true หากปุ่มนี้ถูกเปิดใช้งานด้วยเมาส์สุดพิเศษหลังจากที่ได้ถูกเปิดใช้งานผ่านฟังก์ชัน Plugin:Activate()
ยกเลิกชิ้นส่วนที่ให้และส่งผลกลับ NegateOperations
ใช้เพื่อเปิดตัวสคริปต์ที่กำหนดในหน้าต่างเอ็ดเตอร์ใน Roblox Studio ที่ให้ไว้ หากไม่มีตัวอักษรใดๆ ให้เป็น 1
เปิดหน้าต่างช่วยเหลือบริบที่เกี่ยวข้องกับหน้าวิกิพิเดียที่ url เชื่อมโยงไป
เปิดหน้าต่างการอัปโหลดสำหรับการเลือกปัจจุบันของผู้ใช้
ใช้งานเครื่องมือ Roblox Studio ที่กำหนด
แยกการดำเนินการของสหภาพที่ให้และส่งคืนชิ้นส่วนที่เกิดขึ้น
คีย์ค่านี้จะคงอยู่แม้ว่าสตูดิโอจะปิด
เริ่มการลากที่มีพจนานุกรมของตัวแปร
ผสานชิ้นส่วนที่ให้และรวมกลับ UnionOperation ที่เกิดขึ้น
- CreateDockWidgetPluginGui(pluginGuiId : string,dockWidgetPluginGuiInfo : DockWidgetPluginGuiInfo):DockWidgetPluginGui
สร้าง DockWidgetPluginGui ที่มี DockWidgetPluginGuiInfo
ส่งคำขอให้ผู้ใช้เปิดไฟล์ .fbx ที่สามารถโหลดได้บน rigModel แล้วจากนั้นจะดึงแอนิเมชันเป็น KeyframeSequence ใน Workspace
ส่งคำขอให้ผู้ใช้เปิดไฟล์ .fbx, อัปโหลดส่วนประกอบแต่ละอันของแบบจำลองเป็นเมช, และสร้างตัวละครริกให้ใช้ในอนิเมชันซึ่งโหลดใน Workspace
เปิดหน้าต่างใน Roblox Studio ซึ่งเรียกร้องให้ผู้ใช้เลือกสินทรัพย์ตามที่ระบุไว้ใน assetType ระบุ กลับสิ่งที่ assetId ถูกเลือกหรือ -1 หากหน้าต่างถูกปิด
ส่งคำขอให้ผู้ใช้บันทึกการเลือกปัจจุบันของพวกเขาด้วยชื่อไฟล์ที่กำหนด กลับไปที่จริงถ้าผู้ใช้บันทึกไฟล์
อีเวนต์
ไฟร์เมื่อปลั๊กอินถูกปิดใช้งาน
เกิดขึ้นทันทีก่อนที่ Plugin จะหยุดทำงาน
คุณสมบัติ
วิธีการ
Activate
ฟังก์ชันนี้ตั้งค่าสถานะของปลั๊กอินที่เรียกให้เป็น "ใช้งาน" ปลั๊กอินสามารถให้การควบคุมด้วยเมาส์ผ่านวิธีการ Plugin:GetMouse() ตัวอันนี้
ในเวลาใด ๆ จะมี 0 หรือ 1 ปลั๊กอินที่เปิดใช้งาน การเปิดใช้งานปลั๊กอินจะทำให้ปลั๊กอินอื่น ๆ ไม่สามารถใช้งานได้ (พวกเขาจะได้รับเหตุการณ์ Plugin.Deactivation เมื่อเปิดใช้งาน)
ดูเพิ่มเติม:
- Plugin:IsActivatedWithExclusiveMouse() กลับ true หากปุ่มนี้ถูกเปิดใช้งานด้วยเมาส์สุดพิเศษหลังจากที่ได้ถูกเปิดใช้งานผ่านหน้าฟังก์ชันนี้
- Plugin.Unloading ปลดปล่อยโดยทันทีก่อนที่จะปลดปล่อยหรือรีโหลดปลั๊กอินผ่านการอัปเดตหรือการปิดการใช้งาน
พารามิเตอร์
ตัวเลือกบูลีนที่ระบุว่าจะใช้ปลั๊กอินด้วยเมาส์สุดพิเศษหรือไม่ หากเป็นเช่นนั้น PluginMouse สามารถดึงได้ผ่าน Plugin:GetMouse()
ส่งค่ากลับ
CreatePluginAction
คุณสมบัตินี้สร้าง Class.PluginAction ซึ่งเป็นวัตถุที่แทนที่การดำเนินการทั่วไปใน Roblox Studio โดยไม่มี PluginAction หรือ Toolbar โดยตรง ใน Roblo
เมื่อเหตุการณ์ถูกเรียกใช้, กิจกรรม PluginAction.Triggered จะปรากฏขึ้น
เพื่อให้ PluginActions ทำงานได้ตามที่คาดหวังไว้ พวกเขาต้องถูกสร้างโดยการใช้งานนี้
ดูเพิ่มเติม:
- PluginMenu เมนูบริบที่สามารถแสดงใน Studio ซึ่งแสดงรายการของ PluginActions และสนับสนุนสามารถดูสามารถดูสามารถดู
- Plugin:CreatePluginMenu() สร้าง PluginMenu
พารามิเตอร์
ต้องเป็นสตริงที่ไม่ซ้ำกันที่ระบุว่านี่เป็น PluginAction จากคนอื่น
ชื่อแสดงผลของการกระทํา
คำอธิบายที่ปรากฏของการกระทํา
ปลั๊กอิน
ว่า PluginAction จะถูกซ่อนจากมุมมองของลัดสั้นของ Studio หรือไม่ มีประโยชน์สำหรับการดำเนินการบริบูรณ์. ตั้งค่าเริ่มต้นเป็น true
ส่งค่ากลับ
ตัวอย่างโค้ด
This code sample visualizes how to create a PluginAction. These must be created using the Plugin:CreatePluginAction() method in order to work.
In order to work as expected, the code block must but pasted into the Command Bar, but only once. Consecutive attempts at executing the code in the Command Bar will result in an error because a plugin cannot create more than one PluginMenu with the same ID.
When the created action is bound and Triggered, it outputs Hello world!.
local pluginAction = plugin:CreatePluginAction(
"HelloWorldAction",
"Hello World",
"Prints a 'Hello world!'",
"rbxasset://textures/sparkle.png",
true
)
pluginAction.Name = "Test Action"
local function actionTriggered()
print("Hello world!")
end
pluginAction.Triggered:Connect(actionTriggered)
CreatePluginMenu
ฟังก์ชันนี้สร้าง PluginMenu ใหม่ซึ่งเป็นเมนูบริบที่สามารถแสดงใน Studio ที่แสดงรายการ PluginActions และสนับสนุนสารบัญ
เพื่อให้ PluginMenus ทำงานได้ตามที่คาดหวังพวกเขาจะต้องสร้างโดยใช้ฟังก์ชันนี้
ดูเพิ่มเติม:
- PluginAction เป็นวัตถุที่แทนที่การกระทําที่เป็นไปได้ใน Roblox Studio โดยไม่มี Toolbar หรือ Enum.Button โดยตรง
- Plugin:CreatePluginAction() สร้าง PluginAction
- PluginMenu.Title คือข้อความที่จะแสดงเมื่อใช้เป็นลิงค์ลูก
- PluginMenu.Icon ไอคอนที่จะปรากฏเมื่อใช้เป็นลิงค์ลูก
- PluginMenu:AddAction() เพิ่มการกระทำที่ให้ไว้ในเมนู
- PluginMenu:AddNewAction() สร้างการกระทําชั่วคราวที่ซ่อนอยู่จากหน้าต่างการตั้งค่าลัดของ Studio
- PluginMenu:AddMenu() เพิ่มเมนูที่ให้ไว้เป็นแผงคั่ว
- PluginMenu:AddSeparator() เพิ่มเครื่องแยกระหว่างรายการในเมนู
- PluginMenu:Clear() ล้างเมนู
- PluginMenu:ShowAsync() แสดงรายการในเมาส์ของผู้ใช้ ให้ผลจนกว่าจะมีการเลือกรายการหรือปิดเมาส์
พารามิเตอร์
รหัสเฉพาะสำหรับเมนู
ข้อความที่จะปรากฏเมื่อใช้เป็นลิงค์ย่อ
ไอคอนที่จะปรากฏเมื่อใช้เป็นสมุดย่อ
ส่งค่ากลับ
ตัวอย่างโค้ด
This code sample visualizes how PluginMenus and PluginActions behave when created for a Plugin. Outside of this example, you should not parent the plugin or its functional components to the experience's workspace.
In order to work as expected, the code block must but pasted into the Command Bar, but only once. Consecutive attempts at executing the code in the Command Bar will result in an error because a plugin cannot create more than one PluginMenu with the same ID.
After executing the code, changing the created BoolValue in the experience's workspace opens the plugin's menus. Selecting an action from the menus the function connected to the trigger signal.
-- This code can be pasted into the command bar, but only once
local pluginMenu = plugin:CreatePluginMenu(math.random(), "Test Menu")
pluginMenu.Name = "Test Menu"
pluginMenu:AddNewAction("ActionA", "A", "rbxasset://textures/loading/robloxTiltRed.png")
pluginMenu:AddNewAction("ActionB", "B", "rbxasset://textures/loading/robloxTilt.png")
local subMenu = plugin:CreatePluginMenu(math.random(), "C", "rbxasset://textures/explosion.png")
subMenu.Name = "Sub Menu"
subMenu:AddNewAction("ActionD", "D", "rbxasset://textures/whiteCircle.png")
subMenu:AddNewAction("ActionE", "E", "rbxasset://textures/icon_ROBUX.png")
pluginMenu:AddMenu(subMenu)
pluginMenu:AddSeparator()
pluginMenu:AddNewAction("ActionF", "F", "rbxasset://textures/sparkle.png")
local toggle = Instance.new("BoolValue")
toggle.Name = "TogglePluginMenu"
toggle.Parent = workspace
local function onToggled()
if toggle.Value then
toggle.Value = false
local selectedAction = pluginMenu:ShowAsync()
if selectedAction then
print("Selected Action:", selectedAction.Text, "with ActionId:", selectedAction.ActionId)
else
print("User did not select an action!")
end
end
end
toggle.Changed:Connect(onToggled)
CreateToolbar
ฟังก์ชัน สร้างลังเก็บของ สร้างลังเก็บของใหม่ด้วยชื่อที่กำหนด แล้วให้แถบเครื่องมือใช้เพื่อสร้างปุ่มปลั๊กอิน
พารามิเตอร์
ข้อความที่มองเห็นได้ในแถบเครื่องมือ มีชื่อกลุ่มของปุ่มที่อยู่ภายใน
ส่งค่ากลับ
ตัวอย่างโค้ด
This code creates a toolbar with the name "ExampleToolbar".
plugin:CreateToolbar("ExampleToolbar")
Deactivate
ปิดใช้งานปลั๊กอิน สิ่งนี้จะปลดปล่อย PluginMouse ที่เกี่ยวข้องหากมันถูกเปิดใช้งาน
ดูเพิ่มเติม:
- Plugin:Activate() ตั้งค่าสถานะของปลั๊กอินที่เรียกใช้เป็น "ใช้งาน"
- Plugin.Deactivation เปิดใช้งานเมื่อปลั๊กอินถูกปิดใช้งาน
- Plugin.Unloading ปลดปล่อยโดยทันทีก่อนที่จะปลดปล่อยหรือรีโหลดปลั๊กอินผ่านการอัปเดตหรือการปิดการใช้งาน
ส่งค่ากลับ
GetMouse
เก็ตเมาส์ กลับค่า PluginMouse ที่สามารถใช้ได้ในขณะที่ปลั๊กอินกำลังใช้งานผ่าน Plugin:Activate()
ส่งค่ากลับ
ตัวอย่างโค้ด
This code would print Button 1 pressed from PluginMouse each time the mouse's left button was clicked.
local mouse = plugin:GetMouse()
local function button1Down()
print("Button 1 pressed from PluginMouse")
end
mouse.Button1Down:Connect(button1Down)
GetSelectedRibbonTool
เก็บเครื่องมือลายเส้นที่เลือกมาแล้วไปที่ Enum.RibbonTool เพื่อส่งคืนเครื่องมือที่ตรงกัน นี่จะกลับมาเป็นตัวเลือกของเครื่องมือโดยตรงหรือผ่าน Plugin:SelectRibbonTool()
ส่งค่ากลับ
ตัวอย่างโค้ด
This code must be run from a plugin. This code selects the move tool, checks which tool is selected, then prints out to the console which tool is selected. SelectRibbonTool will not return the value until the next frame.
plugin:SelectRibbonTool(Enum.RibbonTool.Move, UDim2.new())
task.wait() -- wait for next frame
local selectedRibbonTool = plugin:GetSelectedRibbonTool()
print("The selected RibbonTool is", selectedRibbonTool)
GetSetting
คีย์
เนื่องจากมีหลายตัวอินสแตนซ์ของปลั๊กอินเดียวกันสามารถทำงานได้พร้อมกัน (เช่นเมื่อหน้าต่าง Studio หลายแผงเปิดอยู่) คุณจึงไม่ควรพึ่งพาค่านี้เป็นเวลาที่เหมือนกัน อินสแตนซ์ปลั๊กอินอื่นๆ สามา
การโทรนี้สามารถล้มเหลวได้อย่างเงียบและกลับมาที่ nil หากมีหลายตัวอย่างของปลั๊กอินเดียวกันกำลังอ่านและเขียนข้อมูล หากปลั๊กอินของคุณคาดหวังว่าจะเขียนไปยั
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
The below example would print the value saved to the key FirstTime. If the key doesn't exist, it would print nil.
local RAN_BEFORE_KEY = "RanBefore"
local didRunBefore = plugin:GetSetting(RAN_BEFORE_KEY)
if didRunBefore then
print("Welcome back!")
else
plugin:SetSetting(RAN_BEFORE_KEY, true)
print("Welcome! Thanks for installing this plugin!")
end
IsActivated
ฟังก์ชันนี้จะกลับคืน true หากปุ่มนี้ถูกเปิดใช้งานอยู่ในขณะนี้หลังจากที่ได้ถูกเปิดใช้งานผ่านฟังก์ชัน Plugin:Activate()
ส่งค่ากลับ
บูโคลนที่แสดงว่าปลั๊กอินกำลังใช้งานอยู่หรือไม่
IsActivatedWithExclusiveMouse
ฟังก์ชันนี้จะกลับคืน true หากปุ่มนี้ถูกเปิดใช้งานด้วยเมาส์สุดพิเศษหลังจากได้รับการเปิดใช้งานผ่าน ฟังก์ชัน Plugin:Activate() หากฟังก์ชันนี้จะกลับคืน true สามารถดึง
ดูเพิ่มเติม:
- Plugin.Deactivation เปิดใช้งานเมื่อปลั๊กอินถูกปิดใช้งาน
- Plugin.Unloading ปลดปล่อยโดยทันทีก่อนที่จะปลดปล่อยหรือรีโหลดปลั๊กอินผ่านการอัปเดตหรือการปิดการใช้งาน
ส่งค่ากลับ
ว่าปลั๊กอินนี้เปิดใช้งานด้วยเมาส์ที่เฉพาะ
Negate
ยกเลิกชิ้นส่วนที่ให้และส่งผลกลับ NegateOperations
พารามิเตอร์
ส่งค่ากลับ
OpenScript
ใช้เพื่อเปิดตัวสคริปต์ที่กำหนดในหน้าต่างเอ็ดเตอร์ใน Roblox Studio ที่ให้ไว้ หากไม่มีตัวอักษรใดๆ ให้เป็น 1
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
The following would open a newly created Script in Workspace, assuming the variable "Plugin" was already declared.
local newScript = Instance.new("Script")
newScript.Parent = workspace
plugin:OpenScript(newScript)
OpenWikiPage
เปิดหน้าต่างช่วยเหลือบริบที่เกี่ยวข้องกับหน้าวิกิพิเดียที่ url เชื่อมโยงไป
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
The following, when executed in a plugin, will open the BasePart API page in the context help.
plugin:OpenWikiPage("API:Class/BasePart")
SaveSelectedToRoblox
เปิดหน้าต่างการอัปโหลดสำหรับการเลือกปัจจุบันของผู้ใช้
ส่งค่ากลับ
SelectRibbonTool
เปิดใช้งานเครื่องมือ Roblox Studio ที่ระบุไว้ หากเครื่องมือเปิดหน้าต่าง ตัวแปรตำแหน่งระบุว่าควรแสดงตำแหน่งที่หน้าจอ
หมายเหตุ:
- ต้องเลือกวัตถุเพื่อให้สิ่งนี้ทำงานได้อย่างถูกต้อง
- การเปลี่ยนแปลงสายล่ามขนาดของสมบัติรุ่น position จะไม่ส่งผลกระทบต่อป๊อปอัปกระบวนการโต้ตอบ
พารามิเตอร์
ส่งค่ากลับ
Separate
แยกการดำเนินการของสหภาพที่ให้และส่งคืนชิ้นส่วนที่เกิดขึ้น
พารามิเตอร์
ส่งค่ากลับ
SetSetting
เก็บค่าที่กำหนดไว้สำหรับการใช้งานในภายหลังตามกุญแจที่กำหนด ค่านี้จะคงอยู่แม้ว่า Roblox Studio จะปิด การตั้งค่าเหล่านี้จะถูกบันทึกในรูปแบบ JSON เป็นแผนที่ด้วยตัวอักษรสตริง ตัวแปรจะถูกแปลง
หมายเหตุว่ารูปแบบ JSON กำหนดข้อจำกัดเพิ่มเติมรวมถึงตัวอักษรต่อไปนี้ซึ่งสามารถทำให้ไฟล์การตั้งค่าเสียหายได้:
- Backslashes ( \ ) ใน keys หรือ values โดยเฉพาะอย่างยิ่งของ escape ของข้อความ ( \" )
- เส้นใหม่ ( \n ) ในกุญแจ
- อ้างอิง ( " ) ในกุญแจ
- ระยะเวลา ( ) ในกุญแจ
การโทรละเมิดสามารถล้มเหลวได้อย่างเงียบเมื่อมีหลายตัวอย่างของปลั๊กอินเดียวกันกำลังอ่านและเขียนข้อมูลอยู่ หากปลั๊กอินของคุณคาดหวังว่าจะเขียนในตั้งค่าบ่อย คุณสามารถตรวจสอบได
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
This code sample demonstrates use of the Plugin:GetSetting() and Plugin:SetSetting() functions. They detect if a plugin is running for the first time by setting a key. If the key is true, it prints a "welcome back" message; otherwise it prints a "first run" message and sets the key to true.
local RAN_BEFORE_KEY = "RunBefore"
local hasRunBefore = plugin:GetSetting(RAN_BEFORE_KEY)
if hasRunBefore then
print("Welcome back!")
else
print("Thanks for installing this plugin!")
plugin:SetSetting(RAN_BEFORE_KEY, true)
end
StartDrag
เริ่มลาก เริ่มการลากโดยใช้พจนานุกรมของตัวแปร ตัวแปรมีดังต่อไปนี้:
<tbody><tr><td><b>ผู้ส่ง</b></td><td>สตริง</td><td><code>""</code></td><td>ระบุที่มาของการลากจากเป้าหมายลง</td></tr><tr><td><b>MimeType</b></td><td>สตริง</td><td><code>""</code></td><td>ประเภท <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types">MIME</a> ของ <b>ข้อมูล</b></td></tr><tr><td><b>ข้อมูล</b></td><td>สตริง</td><td><code>""</code></td><td>แอ็คชันเช่นสิ่งที่กำลังลาก</td></tr><tr><td><b>ไอคอนเมาส์</b></td><td><code>ข้อมูลประเภท.Content</code></td><td><code>""</code></td><td>ไอคอนที่ใช้สำหรับเมาส์เมาส์ในระหว่างการลาก. หากว่างเปล่าจะใช้เมาส์เริ่มต้น</td></tr><tr><td><b>ลากไอคอน</b></td><td><code>ข้อมูลประเภท.Content</code></td><td><code>""</code></td><td>รูปภาพที่จะเรนเดอร์ภายใต้เมาส์ขณะลาก. นี่ควรจะแทนที่รายการที่ลาก</td></tr><tr><td><b>จุดร้อน</b></td><td><code>Datatype.Vector2</code></td><td><code>Datatype.Vector2.new(0, 0)</code></td><td>ค่าเลี้ยวซ้ายจากด้านบนซ้ายที่ผู้ใช้ต้องการให้เมาส์ "หยุด" ไอคอน <b>ลาก</b></td></tr></tbody>
ชื่อ | ชนิด | เริ่มต้น | คำอธิบาย |
---|
ดูเพิ่มเติม:
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
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)
Union
ผสานชิ้นส่วนที่ให้และรวมกลับ UnionOperation ที่เกิดขึ้น
พารามิเตอร์
ส่งค่ากลับ
CreateDockWidgetPluginGui
CreateDockWidgetPluginGui สร้าง DockWidgetPluginGui ใหม่จาก DockWidgetPluginGuiInfo ค่าตัวแรก, 0> uginGuiId0> ควรเป็นสตริงที่เป็นเอกลักษณ์และคงที่ มันใช้เพื
พารามิเตอร์
รหัสประจำตัวเฉพาะที่มีความสม่ำเสมอและความเป็นเอกลักษณ์ในการเก็บสถานะของชุดเรือและรายละเอียดภายในอื่น ๆ
อธิบาย DockWidgetPluginGui เพื่อสร้าง (สถานะเริ่มต้นขนาด, ฯลฯ)
ส่งค่ากลับ
ตัวอย่างโค้ด
This code, when ran inside a Plugin, creates a DockWidgetPluginGui with a simple TextButton.
-- Create new 'DockWidgetPluginGuiInfo' object
local widgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float, -- Widget will be initialized in floating panel
true, -- Widget will be initially enabled
false, -- Don't override the previous enabled state
200, -- Default width of the floating window
300, -- Default height of the floating window
150, -- Minimum width of the floating window (optional)
150 -- Minimum height of the floating window (optional)
)
-- Create new widget GUI
local testWidget = plugin:CreateDockWidgetPluginGui("TestWidget", widgetInfo)
local testButton = Instance.new("TextButton")
testButton.BorderSizePixel = 0
testButton.TextSize = 20
testButton.TextColor3 = Color3.new(1, 0.2, 0.4)
testButton.AnchorPoint = Vector2.new(0.5, 0.5)
testButton.Size = UDim2.new(1, 0, 1, 0)
testButton.Position = UDim2.new(0.5, 0, 0.5, 0)
testButton.SizeConstraint = Enum.SizeConstraint.RelativeYY
testButton.Text = "Click Me"
testButton.Parent = testWidget
ImportFbxAnimation
ฟังก์ชันนี้เรียกให้ผู้ใช้เปิดไฟล์แอนิเมชัน .fbx ที่สามารถโหลดได้บน rigModel แล้วดําเนินการใส่แอนิเมชันเป็น KeyframeSequence ใน Workspace
พารามิเตอร์
ส่งค่ากลับ
ImportFbxRig
ส่งคำขอให้ผู้ใช้เปิดไฟล์ .fbx, อัปโหลดส่วนประกอบแต่ละอันของแบบจำลองเป็นเมช, และสร้างตัวละครริกให้ใช้ในอนิเมชันซึ่งโหลดใน Workspace
พารามิเตอร์
ส่งค่ากลับ
PromptForExistingAssetId
เปิดหน้าต่างใน Roblox Studio ซึ่งเรียกร้องให้ผู้ใช้เลือกสินทรัพย์ตามที่ระบุไว้ใน assetType ระบุ กลับสิ่งที่ assetId ถูกเลือกหรือ -1 หากหน้าต่างถูกปิด
พารามิเตอร์
ส่งค่ากลับ
อีเวนต์
Deactivation
เกิดขึ้นเมื่อ Plugin ถูกปิดใช้งาน สิ่งนี้เกิดขึ้นเมื่อรหัสปลั๊กอินเรียก Plugin:Deactivate() หรือเพราะปลั๊กอินอื่นเรียก Plugin:Activate() ซึ่งบังคับให้ปลั�
ดูเพิ่มเติม:
- Plugin.Unloading ปลดปล่อยโดยทันทีก่อนที่จะปลดปล่อยหรือรีโหลดปลั๊กอินผ่านการอัปเดตหรือการปิดการใช้งาน
Unloading
เหตุการณ์นี้จะเกิดขึ้นโดยทันทีก่อนที่ Plugin จะหยุดวิ่ง ปลั๊กอินจะถูกถอนการโหลดเมื่อปิดการใช้งาน การติดตั้งจะถูกกำจัดออกเมื่อกำลังจะปรับปรุง หรือเมื่อสถานที่ปิด
มันช่วยให้ปลั๊กอินทำความสะอาดหลังจากตัวเองก่อนที่จะหยุดวิดีโอสคริปต์ทำงาน, เช่น, เพื่อลบตัวอย่างที่ไม่จำเป็นออกจาก DataModel หากปลั๊กอินไม่ทำความสะอา
ตัวอย่างเช่น Class.PluginToolbarButton|PluginToolbarButtons``Class.DockWidgetPluginGui|DockWidgetPluginGuis และ PluginGuis จะปรับปรุงอัตโนมัติเมื่อปลั๊กอินถูกโหลดออกดังนั้นจึงไม่จำเป็นต้องลบพว