PluginGui
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
PluginGui は、様々な Roblox Studio ウィジェットで GuiObjects の表示を可能にするGUIの抽象クラスです。現時点で利用可能な唯一の PluginGui タイプは DockWidgetPluginGui ですが、将来はもっと多くなるかもしれません!
概要
プロパティ
PluginGui のコンテンツの上に表示されるタイトル。
この LayerCollector の表示を切り替えます。
プレイヤーのキャラクターが再スポーンするたびに、 がリセットされるかどうかを決定します。
GuiObject.ZIndex がこの LayerCollector のすべての子孫でどのように振る舞うかを制御します。
ピクセルで、GuiBase2d 要素の実際の画面位置を説明します。
GuiBase2d 要素の実際のスクリーン回転を度数で説明します。
ピクセルで、GuiBase2d 要素の実際の画面サイズを説明します。
true に設定すると、ローカライゼーションがこの GuiBase2d とその子孫に適用されます。
この LocalizationTable とその子孫に自動翻訳を適用するために使用する GuiBase2d の参照。
下方向のゲームパッド選択動作をカスタマイズします。
左方向でゲームパッドの選択動作をカスタマイズします。
右向きにゲームパッドの選択動作をカスタマイズします。
上向きのゲームパッド選択動作をカスタマイズします。
ゲームパッドの選択動作をカスタマイズできます。
方法
機能を PluginGui 閉じるボタンにバインドし、デフォルトの動作を上書きします。
プラグインGUIに対するマウスの位置を返します。
イベント
ユーザーが Plugin:StartDrag() によって開始されたドラッグ操作中に PluginGui の上をホバリングしているときにマウスをリリースするときに発火します。
ユーザーのマウスが Plugin:StartDrag() によって開始されたドラッグ操作中に PluginGui に入ると発火します。
ユーザーのマウスが Plugin:StartDrag() によって開始されたドラッグ操作中に PluginGui を離れると発火します。
ユーザーのマウスが Plugin:StartDrag() によって開始されたドラッグ操作中に PluginGui 内を移動すると発火します。
ユーザーが PluginGui のウィンドウとのインタラクションを停止すると、発火します。
ユーザーが PluginGui のウィンドウと対話を開始すると、発火します。
- SelectionChanged(amISelected : boolean,previousSelection : GuiObject,newSelection : GuiObject):RBXScriptSignal
ゲームパッドの選択が移動し、離れ、または接続された またはその子孫の中で変更されると、炎が発生します。
プロパティ
方法
BindToClose
この関数は、機能を PluginGui 閉じるボタンにバインドし、デフォルトの動作を上書きします。
デフォルトでは、ユーザーが右上隅の PluginGui プロパティの 'x' ボタンをクリックすると、Enabled プロパティが 偽り に設定され、ウィンドウが閉じます。カスタム関数を BindToClose を使用してバインドすると、この動作が上書きされ、ユーザーが本当にウィンドウを閉じるか、作業を保存する機会を与えたいかどうかをチェックできます。
デフォルトの閉じる動作がこの関数によって上書きされるため、PluginGui を手動で閉じるように設定して PluginGui.Enabled を false に設定する必要があります。たとえば、以下のスニペットでは、ユーザーが確認ボタンをクリックしてGUIを閉じる必要があります:
local closing = false
pluginGui:BindToClose(function()
-- すでにボタンを作成していないことを確認する
if closing then
return
end
closing = true
-- 作成確認ボタンを作成する
local confirmButton = Instance.new("TextButton")
confirmButton.AnchorPoint = Vector2.new(0.5, 0.5)
confirmButton.Size = UDim2.new(0.5, 0, 0.5, 0)
confirmButton.Position = UDim2.new(0.5, 0, 0.5, 0)
confirmButton.BackgroundColor3 = Color3.new(1, 0, 0)
confirmButton.Text = "Close?"
confirmButton.Parent = pluginGui
-- クリックを聞く
confirmButton.Activated:Connect(function()
-- gui を閉じる
pluginGui.Enabled = false
-- 削除確認ボタンを削除
confirmButton:Destroy()
end)
end)
BindToClose に引数を与えずに 'unbind' し、上記の説明されたデフォルトの動作に戻すことができます。たとえば:
pluginGui:BindToClose()
参照してください:
- DataModel:BindToClose() , これは機能をゲーム終了にバインドするのに使用でき、この機能と混同してはならない
パラメータ
閉じるボタンにバインドする機能。機能が指定されていない場合は、以前に指定された機能が解除されます。
戻り値
GetRelativeMousePosition
GetRelativeMousePosition は、PluginGui の左上隅に対するマウスの位置を返します。返された値は、プラグインGUI にマウス入力が開始したか、または現在マウスがウィンドウ上にホバーしている場合にのみ変更されます。
戻り値
ピクセルで PluginGui に対するマウスの画面位置。
コードサンプル
local RunService = game:GetService("RunService")
local widgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
true,
false, -- Enabled state, override
200,
300, -- Size
150,
150 -- Minimum size
)
local testWidget = plugin:CreateDockWidgetPluginGui("TestWidget", widgetInfo)
function update()
local v2 = testWidget:GetRelativeMousePosition()
testWidget.Title = ("(%d, %d)"):format(v2.x, v2.y)
end
RunService.Stepped:Connect(update)
update()
イベント
PluginDragDropped
PluginDragDropped は、ユーザーが で始まったドラッグ操作中にマウスをリリースすると発動します。
参照してください:
パラメータ
コードサンプル
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)
PluginDragEntered
PluginDragEntered は、PluginGui によって開始されたドラッグ操作中に、ユーザーのマウスが Plugin:StartDrag() に入ると発動します。
このイベントは、ドラッグ操作をドロップできる PluginGuis で「ここにドロップ」UIを表示するのに便利です。このような UI は、PluginDragLeft または PluginDragDropped 発射するときに非表示になるべきです。
参照してください:
パラメータ
元々 Plugin:StartDrag() に渡されたデータのコピー。
コードサンプル
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)
PluginDragLeft
PluginDragLeft は、ユーザーのマウスが PluginGui によるドラッグ操作を開始したときに発動し、Plugin:StartDrag() によるドラッグ操作が終了すると発動します。
このイベントと PluginDragDropped は、ドラッグ操作をドロップできる PluginGuis の "ここにドロップ" UIを非表示にするのに便利です。このような UI は、PluginDragEntered が発動したときに表示されるべきです。
参照してください:
パラメータ
元々 Plugin:StartDrag() に渡されたデータのコピー。
コードサンプル
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)
PluginDragMoved
PluginDragMoved は、PluginGui によって開始されたドラッグ操作中に、ユーザーのマウスが Plugin:StartDrag() 内移動すると発動します。
参照してください:
パラメータ
WindowFocusReleased
WindowFocusReleased は、ユーザーがプラグインGUIのウィンドウとの対話を停止すると、通常ウィンドウに含まれないものをクリックするとすぐに発射します。この機能は、同じく名前の UserInputService.WindowFocusReleased イベントと同様に機能します。
ユーザーがこのプラグインGUIをフォーカスにしている間、焦点が別の PluginGui に移動した場合、このイベントは、他のイベントの WindowFocused より前に発動します。しかし、メインゲームウィンドウが焦点に置かれている場合、このイベントは 後の UserInputService.WindowFocused に発火します。
コードサンプル
This code sample demonstrates how the focus state of a PluginGui can be tracked using the WindowFocused() and WindowFocusReleased() events. It changes the Title() as the focus state changes.
local info = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 200, 50, 1, 1)
local widget = plugin:CreateDockWidgetPluginGui("TestWidget", info)
local function onFocusReleased()
widget.Title = "I'm not in focus :("
end
local function onFocused()
widget.Title = "I'm in focus :D"
end
widget.WindowFocusReleased:Connect(onFocusReleased)
widget.WindowFocused:Connect(onFocused)
WindowFocused
ウィンドウが焦点になった は、ユーザーが PluginGui のウィンドウと対話を開始するとすぐに発火し、通常はクリックして発生します。この機能は、同じく名前の UserInputService.WindowFocused イベントと同様に機能します。マウスボタンに関連するすべての GuiObject.InputBegan イベントが発生する前に発射します。
もう一つの PluginGui が焦点にあり、ユーザーがこの PluginGui に焦点を合わせている場合、このイベントは他のイベントの WindowFocusReleased 後に発動します。しかし、メインゲームウィンドウが焦点にあった場合、このイベントは 後の UserInputService.WindowFocusReleased に発射します。
コードサンプル
This code sample demonstrates how the focus state of a PluginGui can be tracked using the WindowFocused() and WindowFocusReleased() events. It changes the Title() as the focus state changes.
local info = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, true, 200, 50, 1, 1)
local widget = plugin:CreateDockWidgetPluginGui("TestWidget", info)
local function onFocusReleased()
widget.Title = "I'm not in focus :("
end
local function onFocused()
widget.Title = "I'm in focus :D"
end
widget.WindowFocusReleased:Connect(onFocusReleased)
widget.WindowFocused:Connect(onFocused)