Hey! So I’m experimenting around with plugin and I started wondering - How do we make a Gui possible and not use a instance.new()? I know it’s possible, here’s a example:
What do you mean by that exactly, are you talking about PluginGuis ?
Yes (CharacterLimitMomentAAAAAA)
They may be kept in a script and then parented to StarterGui or CoreGui idk
1 Like
4ny5
(rOOt)
January 19, 2022, 12:21pm
#5
not sure what you mean about this can you give me another example?
Like when you click a plugin and a Gui appears.
Do you mean when it should open and when it should close using a button gui? Then this is probably your answer.
I just tested this out and you don’t even need to save if your PluginGui was enabled. Roblox handles that for you. All you need is a button to toggle the enabled state so that the user can turn it back on if they close it.
Check out this example:
local pluginGui = plugin:CreateDockWidgetPluginGui(
"Test_Dockable_Widget",
DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float, -- Window will be initialized in a floating state.
true,
false, -- Don't override the saved enabled/dock state.
200, -- Width of the floating window.
100 -- Height of the floating window.
)
)
local testBtn = Instance.new("TextButton")
testBtn.TextScaled = true
testBtn.AnchorPoint = Vector2.new(0.5,0.5)
testBtn.Size = UDim2.new(1,0,1,0)
testBtn.Position = UDim2.new(0.5,0,0.5,0)
testBtn.SizeConstraint = Enum.SizeConstraint.RelativeYY
testBtn.BackgroundColor3 = Color3.new(1,0.5,0)
testBtn.Text = "I hope I didn't mess this up!!"
testBtn.Parent = pluginGui
button.Click:connect(function()
pluginGui.Enabled = not pluginGui.Enabled
end)
You’re also able to develop your GUI in studio, stick it in your plugin script, then do script.PluginMainFrame:Clone().Parent = pluginGui
so you don’t have to make the whole GUI by script. Some example code:
local pluginGui = plugin:CreateDockWidgetPluginGui(
"Test_Dockable_Widget",
DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float, -- Window will be initialized in a floating state.
true,
false, -- Don't override the saved enabled/dock state.
200, -- Width of the floating window.
100 -- Height of the floating window.
)
)
local mainGui = script.PluginGuiMainFrame:Clone()
mainGui.Parent = pluginGui
-- your hand-made gui is now inside a plugingui!
-- making guis in Studio is a lot easier than making them by script!
button.Click:connect(function()
pluginGui.Enabled = not pluginGui.Enabled
end)
Don’t forget to turn on “Show Plugin GUI Service in Explorer” in the settings so that you can inspect your plugin’s GUI.
I forgot about this, but it appears to be functioning! Thanks!