• UseToolMenus.Edit command in editor
  • See this cool post.
  • See _Resources (Slate) for more details about reusing engine slate icons & styles.
  • See this for dynamic tool menu entries and to get context.
  • See this cool post (use translator) about general extensions (check at the end (FWorkflowCentricApplication section) for a cool example of using a FSummoner).

Contexts

You can get the context of a ToolbarSection if using MyToolMenuSection.AddDynamicEntry.

Example:

UToolMenu* ToolbarMenu = UToolMenus::Get()->ExtendMenu("Kismet.SubobjectEditorContextMenu");
FToolMenuSection& ToolbarSection = ToolbarMenu->AddSection("PrefabSystemSection.BlueprintEditor.Component", INVTEXT("PefababSystem"));
  
ToolbarSection.AddDynamicEntry(FName("PrefabReferenceComponentSubMenu"), FNewToolMenuSectionDelegate::CreateLambda([this](FToolMenuSection& InSection)  
{
	// For accuracy, this would be null because we are in a subobject context
	UBlueprintEditorToolMenuContext* BlueprintEditorContext = InSection.FindContext<UBlueprintEditorToolMenuContext>();
	// ...

For example here we are only showing this menu entry if the right clicked component is a UPSPrefabReferenceComponent:

ToolbarSection.AddDynamicEntry(FName("PrefabReferenceComponentSubMenu"), FNewToolMenuSectionDelegate::CreateLambda([this](FToolMenuSection& InSection)  
{  
    USubobjectEditorMenuContext* SubobjectEditorMenuContext = InSection.FindContext<USubobjectEditorMenuContext>();  
	if (SubobjectEditorMenuContext)
	{
		bool bCanShow = false;
		TArray<UObject*> SelectedObjects = SubobjectEditorMenuContext->GetSelectedObjects();
		for (auto& SelectedObject : SelectedObjects)
		{
			auto* Casted = Cast<UPSPrefabReferenceComponent>(SelectedObject);
			if (Casted)
			{
				bCanShow = true;
				break;
			}
		}
	InSection.AddMenuEntry(...)
	// ...
  • UBlueprintEditorToolMenuContext // Appears when the section is in the “main” part of the BP Editor UI
  • UContentBrowserAssetContextMenuContext // for an entry on the right click menu of an CB asset
  • UAssetEditorToolkitMenuContext
  • USubobjectEditorMenuContext // For a subobject entry (ex: component)

Tabs

See https://github.com/aquanox/SubsystemBrowserPlugin/blob/main/Source/SubsystemBrowser/SubsystemBrowserModule.cpp#L49-L76.