概要
方法
AddNewAction(actionId: string,text: string,icon: string):Instance |
AddSeparator():() |
Clear():() |
代码示例
创建一个 PluginMenu 和 PluginMenuAction
-- 此代码可以粘贴到命令栏中,但只能执行一次
local pluginMenu = plugin:CreatePluginMenu(math.random(), "测试菜单")
pluginMenu.Name = "测试菜单"
pluginMenu:AddNewAction("操作A", "A", "rbxasset://textures/loading/robloxTiltRed.png")
pluginMenu:AddNewAction("操作B", "B", "rbxasset://textures/loading/robloxTilt.png")
local subMenu = plugin:CreatePluginMenu(math.random(), "C", "rbxasset://textures/explosion.png")
subMenu.Name = "子菜单"
subMenu:AddNewAction("操作D", "D", "rbxasset://textures/whiteCircle.png")
subMenu:AddNewAction("操作E", "E", "rbxasset://textures/icon_ROBUX.png")
pluginMenu:AddMenu(subMenu)
pluginMenu:AddSeparator()
pluginMenu:AddNewAction("操作F", "F", "rbxasset://textures/sparkle.png")
local toggle = Instance.new("BoolValue")
toggle.Name = "切换插件菜单"
toggle.Parent = workspace
local function onToggled()
if toggle.Value then
toggle.Value = false
local selectedAction = pluginMenu:ShowAsync()
if selectedAction then
print("选择的操作:", selectedAction.Text, "操作Id:", selectedAction.ActionId)
else
print("用户没有选择操作!")
end
end
end
toggle.Changed:Connect(onToggled)API 参考
属性
方法
AddNewAction
AddSeparator
PluginMenu:AddSeparator():()
返回
()
Clear
PluginMenu:Clear():()
返回
()