Download

Remove menu/buttons: is this possible?

Hi, I want to create a “mod” of the unreal editor: I’d like to:

  • replace top file/edit/window/help menus with new menus
  • change contextual menus
  • remove safe / modes / content / etc… buttons and replace them with new buttons.

Is this possible? Do I have to use C++ or is python enough?
Can you give me some hints?
Thank you very much.

Sure it’s possible, but seems like a very heavy handed mod.


"""

  Example of removing existing menu items, and replacing with your own menu

"""

import unreal

def main():

  menus = unreal.ToolMenus.get()

  # Get the main menu,
  main_menu = menus.find_menu("LevelEditor.MainMenu")

  # List all the default registered menus at top of the window,
  menu_to_delete = 
    "MainFrame.MainMenu.File",
    "LevelEditor.MainMenu.File",
    "MainFrame.MainMenu.Edit",
    "LevelEditor.MainMenu.Edit",
    "MainFrame.MainMenu.Window",
    "LevelEditor.MainMenu.Window",
    "MainFrame.MainMenu.Help",
    "LevelEditor.MainMenu.Help",
  ]

  # For each reg istered menu, drop all entries and remove the menu,
  for name in menu_to_delete:
    menus.unregister_owner_by_name(name)
    menus.remove_menu(name)

  # Lastly drop the entries under MainMenu, otherwise we will have
  # menu buttons [File, Edit, Window, Help] without anything under
  menus.unregister_owner_by_name("MainMenu")

  # Add our own submenu
  my_menu = main_menu.add_sub_menu(
    owner = "LevelEditor.MainMenu",
    section_name = "Section",
    name = "My.Menu",
    label = "Fizzbuzz",
    tool_tip = "We replaced the old items with our own!"
  )

  # Just add some entries to this menu for display purposes,
  for name in "Foo", "Bar", "Baz"]:
    e = unreal.ToolMenuEntry(
      name = name,
      type = unreal.MultiBlockType.MENU_ENTRY,
    )
    e.set_label(name)
    my_menu.add_menu_entry("Items", e)

  menus.refresh_all_widgets()

if __name__ == '__main__':
  main()

To get the names I looked in MainMenu.cpp and LevelEditorMenu.cpp

removed-menu.png

You can also set “display ui extension points” through editor settings and have green texts to give you hints on the menu names.

Great, thank you very much!