Add a custom button to the unreal editor Level Editor Toolbar; Part 1
Tue Nov 08 2022 14:07:42 GMT+0000 (UTC)
Saved by
@MaVCArt
#python
import unreal
# -- first let's acquire a global instance we'll need - ToolMenus
tool_menus = unreal.ToolMenus.get()
# -- now we need a handle on the main level editor toolbar instance.
# -- we can use ToolMenus' "find_menu" function for this.
toolbar = tool_menus.find_menu('LevelEditor.LevelEditorToolbar')
# -- now let's create a new menu entry
entry = unreal.ToolMenuEntryExtensions.init_menu_entry(
# owner
toolbar.menu_name,
# name
'MyPythonMenu',
# label
'My Python Menu',
# tooltip
'This is a custom python menu - you can do cool stuff with it!',
# command_type
unreal.ToolMenuStringCommandType.COMMAND,
# custom command type - we don't need to use this
'',
# command string - normally this would be a python command, but we don't need this.
''
)
# -- now that we've created the entry, we can tell unreal it's supposed to be a combo button
entry.type = unreal.MultiBlockType.TOOL_BAR_COMBO_BUTTON
# -- and now we can add the button to the toolbar
toolbar.add_menu_entry('PythonExtensions', entry)
# -- as a final step we need to tell unreal to refresh all menus
tool_menus.refresh_all_widgets()
content_copyCOPY
Comments