-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustom_menu.py
More file actions
36 lines (27 loc) · 1.18 KB
/
custom_menu.py
File metadata and controls
36 lines (27 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unreal
def main():
menus = unreal.ToolMenus.get()
main_menu = menus.find_menu(unreal.Name('LevelEditor.MainMenu'))
if not main_menu:
unreal.log_error("""Failed to find the 'Main' menu. Something is wrong in the force!""")
entry = unreal.ToolMenuEntry(
name='Python.Tools',
type=unreal.MultiBlockType.MENU_ENTRY,
insert_position=unreal.ToolMenuInsert('', unreal.ToolMenuInsertType.FIRST)
)
entry.set_label(unreal.Text('Test Python Command'))
entry.set_tool_tip(unreal.Text(''))
entry.set_string_command(unreal.ToolMenuStringCommandType.PYTHON,
unreal.Name(''),
string='print("hello")'
)
script_menu = main_menu.add_sub_menu(main_menu.get_name(),
unreal.Name('PythonTools'),
unreal.Name('Tool'),
unreal.Text('CustomTools')
)
script_menu.add_menu_entry(unreal.Name('Scripts'), entry)
# refresh the UI
menus.refresh_all_widgets()
if __name__ == '__main__':
main()