Skip to content

Instantly share code, notes, and snippets.

@tlm2021
Last active June 7, 2022 07:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlm2021/4c0af0b6221949d4319718d07150061a to your computer and use it in GitHub Desktop.
Save tlm2021/4c0af0b6221949d4319718d07150061a to your computer and use it in GitHub Desktop.
Adding new toolbar menus in Unreal
/* Continuation of answer to this question:
https://answers.unrealengine.com/questions/587450/how-to-make-a-simple-menu-in-the-editor-with-plugi.html */
void FMyPlugin::StartupModule()
{
FLevelEditorModule& LevelEditorModule =
FModuleManager::LoadModuleChecked<FLevelEditorModule>
(LEVELEDITOR_MODULE_NAME);
TSharedPtr<FExtender> MenuExtender = MakeShareable(new FExtender());
MenuExtender->AddMenuBarExtension(
"Help",
EExtensionHook::After,
nullptr,
FMenuBarExtensionDelegate::CreateRaw(this, &FMyPlugin::AddMenu)
);
LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuExtender));
}
void FMyPlugin::AddMenu(FMenuBarBuilder& MenuBuilder)
{
MenuBuilder.AddPullDownMenu(
LOCTEXT("MenuLocKey", "My Menu"),
LOCTEXT("MenuTooltipKey", "Opens menu for My Plugin"),
FNewMenuDelegate::CreateRaw(this, &FMyPlugin::FillMenu),
FName(TEXT("My Menu")),
FName(TEXT("MyMenuName")));
}
void FMyPlugin::FillMenu(FMenuBuilder& MenuBuilder) {
// Fill it same as in the accepted answer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment