Insert Position
Controlling where a Menu Entry is inserted
The New __init__
@unreal.uclass()
class PythonMenuTool(unreal.ToolMenuEntryScript):
name = "inserted_menu"
label = "Inserted Menu Class"
tool_tip = "tool tip!"
def __init__(self, menu, section="", insert_policy=None):
"""Initialize our entry for the given menu_object's section"""
super().__init__()
# Initialize the entry data
self.init_entry(
owner_name="custom_owner",
menu=menu.menu_name,
section=section,
name=self.name,
label=self.label,
tool_tip=self.tool_tip
)
# if an insert policy was provided
if insert_policy:
# Build the entry insert object
entry = unreal.ToolMenuEntry(
name=self.name,
type=self.data.advanced.entry_type,
owner=unreal.ToolMenuOwner("custom_owner"),
insert_position=insert_policy,
script_object=self
)
# insert policy method
menu.add_menu_entry(section, entry)
else:
# default method - add at the bottom of the menu
menu.add_menu_entry_object(self)Creating the Insert Position Object
Run it!
The results:

Last updated