Bootstrap Chameleon Logo

Menu Tools Anchor

Stones from other hills can be used to polish gems

Starting from Unreal 4.2x, the Tool Menu feature was added to allow users to add menus to the engine using Python at specified Tool Menu Anchor locations.

TAPython added support for Tool Menu Anchor in v1.0.10, allowing menus and options to be added to any position where Tool Menu can be added.

Menu items created with Tool Menu Anchor

Examples

Component Context Menu

For example, the following code adds a menu item to the Component context menu. The Tool Menu Anchor used here is "Kismet.SubobjectEditorContextMenu".

MenuConfig.json

"Kismet.SubobjectEditorContextMenu": {
    "HasSection": false,
    "items": [
    {
        "name": "Kismet.SubobjectEditorContextMenu",
        "command": "print(unreal.PythonBPLib.get_selected_components())", "icon": { "style": "ChameleonStyle", "name": "Resources.PythonChameleonIcon_40x_png" }
    }]
},

Each menu item using Tool Menu Anchor in MenuConfig.json is independent. Other items, such as "OnMainMenu" and "OnSelectFolderMenu", are on the same level.

Of course, in addition to directly executing Python commands, you can also specify the Chameleon Tool to open after clicking through the "ChameleonTools" field. So all the fields available in other menu items are equally effective here.

It is worth mentioning that when we add menu items to the Toolbar through Tool Menu Anchor, the default Section header makes the button look strange, so we use "HasSection": false to hide this Section header.

image_name

TIP
When the "HasSection" field is not written, the default is true, meaning the Section header is added.

Refreshing Tool Menu

Tool Menu Anchor is a built-in feature of Unreal Engine, and its registration is different from other TAPython menu items. Currently, menu items added using the Tool Menu Anchor field cannot be automatically refreshed, so manual refresh is required. Here we use a Cmd debug command TAPython.RefreshToolMenus to refresh the Tool Menu. As shown in the image above, after modifying MenuConfig.json, we can refresh the Tool Menu by typing TAPython.RefreshToolMenus in the Console.

TIP
This is a Cmd debug command, not a Python command.

TAPython.RefreshToolMenus 

Tool Menu Anchors

I scanned all Tool Menu Anchors in UE5.1 using a script, and the following is a list I compiled for reference.

Available Tool Menu Anchors include, but are not limited to, the following:

  • AssetEditor.AnimationBlueprintEditor.MainMenu
  • AssetEditor.AnimationEditor.MainMenu
  • AssetEditor.SkeletalMeshEditor.ToolBar
  • AssetEditor.StaticMeshEditor.ToolBar
  • ContentBrowser.AddNewContextMenu
  • ContentBrowser.AssetContextMenu
  • ContentBrowser.AssetContextMenu.AimOffsetBlendSpace
  • ContentBrowser.AssetContextMenu.AnimBlueprint
  • ContentBrowser.AssetContextMenu.AnimMontage
  • ContentBrowser.AssetContextMenu.AnimSequence
  • ContentBrowser.AssetContextMenu.BlendSpace
  • ContentBrowser.AssetContextMenu.BlendSpace1D
  • ContentBrowser.AssetContextMenu.CameraAnim
  • ContentBrowser.AssetContextMenu.DatasmithScene
  • ContentBrowser.AssetContextMenu.PoseAsset
  • ContentBrowser.AssetContextMenu.SkeletalMesh
  • ContentBrowser.AssetContextMenu.SkeletalMesh.CreateSkeletalMeshSubmenu
  • ContentBrowser.AssetContextMenu.Skeleton.CreateSkeletalMeshSubmenu
  • ContentBrowser.AssetContextMenu.SoundWave
  • ContentBrowser.AssetContextMenu.StaticMesh
  • ContentBrowser.AssetContextMenu.World
  • ContentBrowser.AssetViewOptions
  • ContentBrowser.AssetViewOptions.PathViewFilters
  • ContentBrowser.DragDropContextMenu
  • ContentBrowser.FolderContextMenu
  • ContentBrowser.ItemContextMenu.PythonData
  • ContentBrowser.ToolBar
  • ControlRigEditor.RigHierarchy.ContextMenu
  • ControlRigEditor.RigHierarchy.DragDropMenu
  • Kismet.SubobjectEditorContextMenu
  • Kismet.SCSEditorContextMenu
  • LevelEditor.ActorContextMenu.AssetToolsSubMenu
  • LevelEditor.ActorContextMenu.LevelSubMenu
  • LevelEditor.InViewportPanel
  • LevelEditor.LevelEditorSceneOutliner.ContextMenu.LevelSubMenu
  • LevelEditor.LevelEditorToolBar
  • LevelEditor.LevelEditorToolBar.AddQuickMenu
  • LevelEditor.LevelEditorToolBar.User
  • LevelEditor.LevelViewportToolBar.Options
  • LevelEditor.LevelViewportToolBar.View
  • ~~- LevelEditor.MainMenu~~
  • LevelEditor.MainMenu.Build
  • LevelEditor.MainMenu.File
  • LevelEditor.MainMenu.Help
  • LevelEditor.MainMenu.Select
  • LevelEditor.MainMenu.Tools
  • LevelEditor.MainMenu.Window
  • LevelEditor.StatusBar.ToolBar
  • MainFrame.MainMenu.Asset
  • MainFrame.MainMenu.Tools
  • MainFrame.MainMenu.Window
  • StatusBar.ToolBar.SourceControl

Reference