Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreal context menus #48

Merged
merged 22 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
52369f8
Added Context arg to the main node,
JLHayde Jul 17, 2023
c984a98
Merge branch 'hannesdelbeke:main' into unreal_context_menus
JLHayde Jul 17, 2023
a381a0e
updated sample text
JLHayde Jul 17, 2023
8829417
Removed context menu argument
JLHayde Jul 17, 2023
3f51e98
isolated context logic to just the unreal app
JLHayde Jul 17, 2023
74e01e7
updated string format
JLHayde Jul 17, 2023
cd5dc91
Set Section names on items and seperators
JLHayde Jul 17, 2023
a63c225
Set Section names on items and seperators
JLHayde Jul 17, 2023
d13314c
Merge remote-tracking branch 'origin/unreal_context_menus' into unrea…
JLHayde Jul 17, 2023
4084a61
did not mean to change that
JLHayde Jul 17, 2023
3e90aa1
updating sample
JLHayde Jul 20, 2023
707078a
Removed root_menu kwarg in favour of parent_path
JLHayde Jul 20, 2023
46730e4
Merge branch 'main' of github.com:JLHayde/unimenu into unreal_context…
JLHayde Jul 20, 2023
d66954f
section change
JLHayde Jul 24, 2023
5b6267c
Merge branch 'main' of github.com:JLHayde/unimenu into unreal_context…
JLHayde Jul 24, 2023
ceb18aa
reset test
JLHayde Jul 24, 2023
3c66b01
reset test
JLHayde Jul 24, 2023
33beb2a
kwargs can now override args for the unreal menus, items and separato…
JLHayde Jul 24, 2023
9134535
Merge branch 'main' of github.com:JLHayde/unimenu into unreal_context…
JLHayde Jul 24, 2023
a83e726
resized image
JLHayde Jul 24, 2023
152af6f
removed random line
JLHayde Jul 24, 2023
5bde8f3
adjusted the command to run from the samples package
JLHayde Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions samples/unreal_context_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ def test_function():


config = {
'label': 'Context Tools',
'parent_path': "StaticMesh",
'context_menu': True,
'label': 'StaticMesh Tools',
'kwargs': {
'root_menu': "ContentBrowser.AssetContextMenu.StaticMesh",
"menu_section": "GetAssetActions"
},

'items':

Expand Down
28 changes: 17 additions & 11 deletions unimenu/apps/unreal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ class MenuNodeUnreal(MenuNodeAbstract):

@property
def _default_root_parent(self):
if not self.use_context_menu:
if self.parent_path:
parent_path = f"LevelEditor.MainMenu.{self.parent_path}" # todo make this more flexible
else:
parent_path = "LevelEditor.MainMenu"
else:
parent_path = f"ContentBrowser.AssetContextMenu.{self.parent_path}"
# Default menu root
parent_path = "LevelEditor.MainMenu"
hannesdelbeke marked this conversation as resolved.
Show resolved Hide resolved

# Optional root
if self.kwargs.get('root_menu'):
# full list of ui names here https://dev.epicgames.com/community/snippets/exo/unreal-engine-editor-ui-menu-names
parent_path = f"{self.kwargs['root_menu']}"

# Extend the root
if self.parent_path:
parent_path = parent_path + f".{self.parent_path}"

unreal_menus = unreal.ToolMenus.get()
parent_menu = unreal_menus.find_menu(parent_path)
Expand All @@ -26,10 +30,12 @@ def setup(self, parent_app_node=None, backlink=True):
unreal_menus.refresh_all_widgets()

def _setup_sub_menu(self, parent_app_node=None) -> unreal.ToolMenu:

# Default Section
target_section_name = "PythonTools"
if self.use_context_menu:
target_section_name = "GetAssetActions"

if self.kwargs.get('menu_section'):
hannesdelbeke marked this conversation as resolved.
Show resolved Hide resolved
# change target section
target_section_name = self.kwargs['menu_section']

return parent_app_node.add_sub_menu(
owner=parent_app_node.menu_name,
Expand Down Expand Up @@ -71,4 +77,4 @@ def _setup_separator(self, parent_app_node=None):

def teardown(self):
"""remove from menu"""
raise NotImplementedError("not yet implemented")
raise NotImplementedError("not yet implemented")