Plugin

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

無法建立

插件 是負責創建基本 Studio 視窗、插件工具欄、插件按鈕等的主要對象。這是一種自訂添加到 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.

Script - Pass the Plugin Global to a ModuleScript

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()
ModuleScript - Receive and Store the Plugin Global

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

概要

屬性

方法

屬性

CollisionEnabled

唯讀
未複製
平行讀取

DisableUIDragDetectorDrags

Roblox 指令碼安全性
平行讀取

GridSize

唯讀
未複製
平行讀取

IsDebuggable

Roblox 指令碼安全性
平行讀取

方法

Activate

()
外掛程式安全性

參數

exclusiveMouse: boolean
預設值:""

返回

()

CreatePluginAction

外掛程式安全性

參數

actionId: string
預設值:""
text: string
預設值:""
statusTip: string
預設值:""
iconName: string
預設值:""
allowBinding: boolean
預設值:true

返回

範例程式碼

Creating a PluginAction

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

外掛程式安全性

參數

id: string
預設值:""
title: string
預設值:""
icon: string
預設值:""

返回

範例程式碼

Creating a PluginMenu and PluginMenuAction

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

外掛程式安全性

參數

name: string
預設值:""

返回

範例程式碼

Plugin:CreateToolbar

plugin:CreateToolbar("ExampleToolbar")

Deactivate

()
外掛程式安全性

返回

()
外掛程式安全性

返回

GetMouse

外掛程式安全性

返回

範例程式碼

Plugin:GetMouse

local mouse = plugin:GetMouse()
local function button1Down()
print("Button 1 pressed from PluginMouse")
end
mouse.Button1Down:Connect(button1Down)

GetSelectedRibbonTool

外掛程式安全性

返回

範例程式碼

Plugin:GetSelectedRibbonTool

plugin:SelectRibbonTool(Enum.RibbonTool.Move, UDim2.new())
task.wait() -- wait for next frame
local selectedRibbonTool = plugin:GetSelectedRibbonTool()
print("The selected RibbonTool is", selectedRibbonTool)

GetSetting

Variant
外掛程式安全性

參數

key: string
預設值:""

返回

Variant

範例程式碼

Plugin:GetSetting

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

Intersect

外掛程式安全性

參數

objects: Instances
預設值:""

返回

IsActivated

外掛程式安全性

返回

IsActivatedWithExclusiveMouse

外掛程式安全性

返回

Negate

Instances
外掛程式安全性

參數

objects: Instances
預設值:""

返回

Instances

OpenScript

()
外掛程式安全性

參數

預設值:""
lineNumber: number
預設值:1

返回

()

範例程式碼

Plugin:OpenScript

local newScript = Instance.new("Script")
newScript.Parent = workspace
plugin:OpenScript(newScript)

OpenWikiPage

()
外掛程式安全性

參數

url: string
預設值:""

返回

()

範例程式碼

Plugin:OpenWikiPage

plugin:OpenWikiPage("API:Class/BasePart")

SaveSelectedToRoblox

()
外掛程式安全性

返回

()

SelectRibbonTool

()
外掛程式安全性

參數

預設值:""
position: UDim2
預設值:""

返回

()

Separate

Instances
外掛程式安全性

參數

objects: Instances
預設值:""

返回

Instances

SetSetting

()
外掛程式安全性

參數

key: string
預設值:""
value: Variant
預設值:""

返回

()

範例程式碼

Plugin:GetSetting and Plugin:SetSetting

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

()
外掛程式安全性

參數

dragData: Dictionary
預設值:""

返回

()

範例程式碼

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)
外掛程式安全性

參數

objects: Instances
預設值:""

返回

CreateDockWidgetPluginGui

暫停
外掛程式安全性

參數

pluginGuiId: string
預設值:""
dockWidgetPluginGuiInfo: DockWidgetPluginGuiInfo
預設值:""

返回

範例程式碼

Widget GUI Text Button

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

暫停
外掛程式安全性

參數

rigModel: Instance
預設值:""
isR15: boolean
預設值:true

返回

ImportFbxRig

暫停
外掛程式安全性

參數

isR15: boolean
預設值:true

返回

PromptForExistingAssetId

暫停
外掛程式安全性

參數

assetType: string
預設值:""

返回

PromptSaveSelection

暫停
外掛程式安全性

參數

suggestedFileName: string
預設值:""

返回

活動

Deactivation

外掛程式安全性

Unloading

外掛程式安全性