Plugin

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建

插件 是负责创建基本 Studio widget、插件工具栏、插件按钮等的主要对象。它是为 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

插件安全性