Option 1: Adding a Menu Button Action

This option involves adding a straightforward actionable button to the editor's menu, which, when clicked, executes a predefined command.

Implementation using RegisterMenus:

cppCopy code// MyModule.cpp

void MyModule::StartupModule()
{
    MyModuleCommands::Register();
    FGlobalTabmanager::Get()->RegisterNomadTabSpawner(MyModuleName, FOnSpawnTab::CreateRaw(this, &MyModule::SpawnMyPluginTab));
}

void MyModule::RegisterMenus()
{
    FToolMenuOwnerScoped OwnerScoped(this);
    UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.MainMenu.Tools");
    FToolMenuSection& Section = Menu->AddSection("MyModuleCommands", LOCTEXT("MyCommands", "My Module Commands"));

    Section.AddMenuEntryWithCommandList(
        MyModuleCommands::Get().OpenPluginWindow,
        PluginCommands,
        NAME_None,
        LOCTEXT("OpenMyWindow", "Open My Window"),
        LOCTEXT("OpenMyWindowTooltip", "Opens my custom plugin window."),
        FSlateIcon(FMyModuleStyle::GetStyleSetName(), "MyCommandIcon")
    );
}

Option 2: Creating a Submenu with Various Options

Creating a submenu allows you to group multiple related actions under a single menu heading, organizing the user interface more effectively.

Implementation using RegisterMenus:

Last updated