Plugin
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
プラグイン は、基本的な 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 をスタジオの [モデル] タブで有効にしているかどうかを返します。
Studio でユーザーが設定したグリッドスナップサイズを返します。
方法
コールプラグインの状態を「有効」に設定します。
- CreatePluginAction(actionId : string,text : string,statusTip : string,iconName : string,allowBinding : bool):PluginAction
Roblox Studio の Roblox プラグインアクションを表示するオブジェクトを作成します PluginAction 、これは Roblox Studio の Roblox プラグインアクションを直接参照することなく、Toolbar または Enum.Button を含めることがありません。
新しいプラグインメニューを作成します。
Class.PluginToolbar を新しく作成し、指定された名前です。
プラグインを無効にします。
スタジオの [モデル] タブの下でユーザーが設定した Enum.JointCreationMode を返します。
プラグインがアクティブな間、Mouse を返します。
現在選択されている Enum.RibbonTool を返します。
以前に保存された値を指定されたキーで取り戻すか、指定されたキーが存在しない場合は、nil を取り戻します。
このプラグインが Plugin:Activate() 機能を通じて有効になっている場合、Class.Plugin:Activate() 機能を通じて有効になるように返します。
このプラグインが Plugin:Activate() 機能を使用して有効になっている場合、また Class.Plugin:Activate() メソッドを通じて有効になった後、返回 は、2> 独占的なマウス2>でこのプラグインがアクティブであることを返します。
与えられたパーツを否定し、結果として NegateOperations を返します。
Roblox Studio の編集モードのスクリプトインスタンスを開くために使用されます。引数が与えられていない場合は、デフォルトで 1 が返されます。
コンテキストヘルプウィンドウを開き、url にリンクされているウィキペディアページを開きます。
ユーザーの現在の選択についてのアップロードウィンドウを開きます。
指定した Roblox Studio ツールを有効にします。
ユニオンオペレーションを与え、結果となるパーツを返します。
指定されたキーの下で、後で使用するために特定の値を保存します。値は、Studio が閉じるときでも持続します。
パラメーターのダイクトリを与えられたドラッグアクションを開始します。
与えられたパーツを結合し、結果として UnionOperation を返します。
- CreateDockWidgetPluginGui(pluginGuiId : string,dockWidgetPluginGuiInfo : DockWidgetPluginGuiInfo):DockWidgetPluginGui
Class.DockWidgetPluginGui を作成し、DockWidgetPluginGuiInfo を渡します。
ユーザーが rigModel にロードできる .fbx アニメーションファイルを開くように促し、その後、アニメーションを KeyframeSequence として Workspace に挿入します。
ユーザーに .fbx ファイルを開くように促し、モデルの個々のコンポーネントをメッシュとしてアップロードし、アニメーションで使用するためのキャラクターリグを生成します。これは Workspace にロードされます。
Roblox Studio のウィンドウを開き、ユーザーが指定した assetType に基づいてアセットを選択します。返したアセットId は、ウィンドウが閉じると -1 または返します。
ユーザーに現在の選択を指定されたファイル名で保存するよう促します。ユーザーがファイルを保存した場合、戻り値は true です。
イベント
プラグインが無効になったときに発動します。
Class.Plugin が実行を停止する直前に即座に Class.Plugin を発動します。
プロパティ
方法
Activate
この関数は、コール中のプラグインの状態を「有効化」に設定します。プラグインを「有効化」すると、マウスコントロールを通過する Plugin:GetMouse() メソッドを通じてマウスコントロールをマウスコントロールをマウスコントロールをマウスコントロールをマウスコントロールをマウスコントロールをマウスコントロールをマウスコントロールをマウスコントロールをマウスコントロールをマウスコントロ
指定された時点には、0個または1個の有効なプラグインがあります。プラグインを有効にすると、他のすべてのプラグインが無効になります (Plugin.Deactivation イベントを受信します)。
参照してください:
- Plugin:IsActivatedWithExclusiveMouse() 、このマウス能を介してアクティブになったプラグインがある場合、 true を返します。
- Plugin.Unloading は、プラグインのアンロードまたは再読み込みを通じてインストールされるため、インストールからすぐに前に発動します
パラメータ
プラグイマウスを有効にするかどうかを指定するBoolean。 true の場合、 PluginMouse は、Plugin:GetMouse() を通じて取得できます。
戻り値
CreatePluginAction
この関数は、Roblox Studio の Roblox プラグインアクションを表示するオブジェクトを作成します。これは、Roblox Studio の「<a href=\"#Class.PluginAction\">Class.PluginAction</a>」、「<a href=\"#Toolbar\">Class.PluginAction</a>」、「<a href=\"#еньекбункен» Class.PluginAction</a>」
アクションがトリガーされると、PluginAction.Triggered イベントがシグナルされます。
プラグインアクションが期待通りに機能するには、この関数を使用して作成する必要があります。
参照してください:
- PluginMenu、Studio で表示されるコンテキストメニュー、プラグインアクションのリストを表示し、サブメニューをサポートします
- Plugin:CreatePluginMenu() 、プラグインメニューを作成します
パラメータ
他のプラグインアクションを識別するユニークな文字列でなければなりません。
操作クションの表示名。
アクションの表示された説明。
プラグインを表示するために使用されるアイコンの名前。
Class.PluginAction がスタジオのショートカットビューから隠されるかどうか。コンテキストアクションに便利。デフォルトは 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 を作成します。PluginActions のリストを表示し、サブメニューをサポートします。
プラグインメニューが期待通りに機能するには、この関数を使用して作成する必要があります。
参照してください:
- Plugin:CreatePluginAction() 、プラグインアクションを作成します
- PluginMenu.Title , サブメニューとして使用されるときに表示されるテキスト
- PluginMenu.Icon 、サブメニューとして使用するときに表示されるアイコン
- PluginMenu:AddAction() 、メニューに指定したアクションを追加します
- PluginMenu:AddNewAction() は、Studio のカスタマイズショートカットウィンドウから隠された一時的なアクションを作成します
- PluginMenu:AddMenu() は、与えられたメニューをセパレータとして追加します
- PluginMenu:AddSeparator() 、メニューのアイテム間のセパレータを追加します
- PluginMenu:Clear() 、メニューをクリアします
- PluginMenu:ShowAsync() は、マウスカーソルのメニューを表示します。選択されたアイテムまたはメニューが閉じるまでには、Yields が続きます。選択されたアクションは、トリガーイベントを発動させます
パラメータ
メニューにユニークなIDを割り当てる。
サブメニューとして使用するテキスト。
サブメニューとして使用するときに表示されるアイコン。
戻り値
コードサンプル
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
ツールバーは、CreateToolbar 関数で、指定された名前で新しい PluginToolbar を作成します。ツールバーは、プラグインボタンを作成するために使用できます。
パラメータ
ツールバーに表示され、ボタンのグループを含む内容をラベル化します。
戻り値
コードサンプル
This code creates a toolbar with the name "ExampleToolbar".
plugin:CreateToolbar("ExampleToolbar")
Deactivate
プラグインを無効にします。これにより、関連する PluginMouse が有効化されなくなります
参照してください:
- Plugin:Activate() は、呼び出しプラグインの状態を「有効化」に設定します
- Plugin.Deactivation 、プラグインが無効になったときに発動します
- Plugin.Unloading は、プラグインのアンロードまたは再読み込みを通じてインストールされるため、インストールからすぐに前に発動します
戻り値
GetMouse
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
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
以前に保存された値を指定されたキーで取り戻すか、指定されたキーが存在しない場合は、nil を取り戻します。
同じプラグインの複数のインスタンスが同時に実行されるため、この値が一度に同じである必要はありません (たとえ多くの Studio ウィンドウが開いている場合)。他のプラグインインスタンスは、設定をいつでも更新できます。
この呼び出しは、複数のインスタンスの同じプラグインがアクティブに読み取り書き込みを行っている場合、nil を返すことがあります。プラグインが期待しているように設定を頻繁に書き込む場合は、この呼び出しの後に数秒間、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
この関数は、Plugin:Activate() 関数を通じて有効になった後、このプラグインが現在有効であることにより、返り値として戻ります。
戻り値
プラグインが現在有効であるかを示すブールーン。
IsActivatedWithExclusiveMouse
この関数は、Plugin:Activate() 関数を通じて有効になった後、このプラグインが現在有効であることを示すように戻ります。これがPluginMouseを取得する方法です。これがPlugin:GetMouse()で取得できます。
参照してください:
- 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 形式は、次のキャラクターを含む追加の制限を強制します。これらのキャラクターは、設定ファイルを破損する可能性があります:
- キーまたは値の後ろにスラッシュ ( \ ) 、特に脱出した引用文 ( \" ) があります。
- 新行 ( \n ) をキーに。
- キーに Quotes ( " ) を含める。
- 期間 ( ) をキーに含める。
同じプラグインのインスタンスがアクティブに読み取って書き込んでいる場合、この呼び出しは失敗することがあります。プラグインが頻繁に設定に書き込むことを期待している場合は、Plugin:GetSetting() を呼び出してデータが適切に書き込まれているかどうかを確認します。
パラメータ
戻り値
コードサンプル
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>データのタイプ <b>MINE</b>。</td></tr><tr><td><b>データ</b></td><td>文字列</td><td><code>""</code></td><td>ドラッグアクションに関する情報、例えば何がドラッグされているか。ドロップターゲットによって使用されるべきです。</td></tr><tr><td><b>マウスアイコン</b></td><td><code>Datatype.Content</code></td><td><code>""</code></td><td>マウスカーソルの使用中に使用するアイコン。空の場合は、デフォルトのカーソルを使用します。</td></tr><tr><td><b>ドラッグアイコン</b></td><td><code>Datatype.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)
CreateDockWidgetPluginGui
CreateDockWidgetPluginGui は、DockWidgetPluginGui を作成します。DockWidgetPluginGuiInfo から、最初のパラメーター、 0> uginGuiId0> 、がユニークで一貫した文字列です。これは、ウィジェットのドック状態の状態とその他の内部詳
パラメータ
ウィジェットのドックステートや他の内部詳細を保存するユニークで一貫した識別子。
Class.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
この機能は、ユーザーが rigModel にロードできる .fbx アニメーションファイルを開くように促し、その後、アニメーションを KeyframeSequence として Workspace に挿入します。
パラメータ
戻り値
ImportFbxRig
ユーザーに .fbx ファイルを開くように促し、モデルの個々のコンポーネントをメッシュとしてアップロードし、アニメーションで使用するためのキャラクターリグを生成します。これは Workspace にロードされます。
パラメータ
戻り値
PromptForExistingAssetId
Roblox Studio のウィンドウを開き、ユーザーが指定した assetType に基づいてアセットを選択します。返したアセットId は、ウィンドウが閉じると -1 または返します。
パラメータ
戻り値
イベント
Deactivation
Class.Plugin が無効になると、これはプラグインコードが Plugin:Deactivate() を呼び出すか、または他のプラグインが Plugin:Activate() を呼び出すため、すべての他のプラグインがアクティブ状態を失います。
参照してください:
- Plugin.Unloading は、プラグインのアンロードまたは再読み込みを通じてインストールされるため、インストールからすぐに前に発動します
Unloading
このイベントは、Plugin の実行を即座に中止するために発動します。プラグインは、無効になった、Plugin を再読み込み、または場所を閉じるときに解読されます。
スクリプトが実行されなくなる前にプラグインが自分自身を清掃するようになります。たとえスクリプトが正常に実行されていても、DataModel の不要なインスタンスを削除する必要があります。プラグインが適切に清掃されない場合は、古いコピーが残ります。これが発生すると、ユーザーは悪いユーーザーエ
プラグイン関連インスタンスの例、PluginToolbarButtons、DockWidgetPluginGuis、およびPluginGuis は、プラグインがアンロードされると自動的にクリーンアップされるため、削除する必要はありません。