I’m trying to add a button or widget to the editor toolbar on editor startup in Unreal.
I am following the official documentation here
https://dev.epicgames.com/community/learning/talks-and-demos/5J9b/unreal-engine-accelerating-your-in-editor-workflows-with-editor-utilities-gdc-2024
The code is running, I can see results of print commands in my Output Log, but it isn’t working. ie I am not getting a new widget or button in my tool bar.
What I need is debugging feedback.
Based on the following code, what debugging steps should I take to narrow down the issue?
The specific code is
# Copyright Epic Games, Inc. All Rights Reserved.
import unreal
menu_owner = "editorUtilities"
tool_menus = unreal.ToolMenus.get()
owning_menu_name = "LevelEditor.LevelEditorToolBar.AssetsToolBar"
@unreal.uclass()
class createEntry_Example(unreal.ToolMenuEntryScript):
@unreal.ufunction(override=True)
def execute(self, context):
registry = unreal.AssetRegistryHelpers.get_asset_registry()
asset = unreal.EditorAssetLibrary.load_asset("/Game/GDC/EUW_ToolbarExample")
bp = unreal.get_editor_subsystem(unreal.EditorUtilitySubsystem).find_utility_widget_from_blueprint(asset)
if bp == None:
bp = unreal.get_editor_subsystem(unreal.EditorUtilitySubsystem).spawn_and_register_tab(asset)
def init_as_toolbar_button(self):
self.data.menu = owning_menu_name
self.data.advanced.entry_type = unreal.MultiBlockType.TOOL_BAR_BUTTON
self.data.icon = unreal.ScriptSlateIcon("PresenterStyle", "Presenter.Logo")
def Run():
entry = createEntry_Example()
entry.init_as_toolbar_button()
entry.init_entry(menu_owner, "editorUtilitiesExampleEntry", "", "", "Example Button", "Opens up an example Editor Utility Widget")
toolbar = tool_menus.extend_menu(owning_menu_name)
toolbar.add_menu_entry_object(entry)
tool_menus.refresh_all_widgets()
Run()