MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / menu_exec

Function menu_exec

unity_cli/cli/commands/menu.py:28–56  ·  view source on GitHub ↗

Execute any Unity menu item by its menu-bar path. Works with: - Built-in menus: 'Edit/Play', 'File/Save', 'Assets/Refresh' - Package menus: 'Window/Package Manager', 'Window/Analysis/Profiler' - Custom tools: any [MenuItem("Path/To/Action")] defined in your project Use

(
    ctx: typer.Context,
    path: Annotated[str, typer.Argument(help="Menu item path (e.g., 'Edit/Play', 'Tools/MyCustomAction')")],
)

Source from the content-addressed store, hash-verified

26
27@menu_app.command("exec")
28def menu_exec(
29 ctx: typer.Context,
30 path: Annotated[str, typer.Argument(help="Menu item path (e.g., 'Edit/Play', 'Tools/MyCustomAction')")],
31) -> None:
32 """Execute any Unity menu item by its menu-bar path.
33
34 Works with:
35 - Built-in menus: 'Edit/Play', 'File/Save', 'Assets/Refresh'
36 - Package menus: 'Window/Package Manager', 'Window/Analysis/Profiler'
37 - Custom tools: any [MenuItem("Path/To/Action")] defined in your project
38
39 Use 'u menu list' (optionally with --filter) to discover available menu paths.
40
41 Examples:
42 u menu exec 'Edit/Play'
43 u menu exec 'Assets/Refresh'
44 u menu exec 'Window/Rendering/Lighting'
45 u menu exec 'Tools/RegenerateData' # custom [MenuItem]
46 """
47 context: CLIContext = ctx.obj
48 try:
49 result = context.client.menu.execute(path)
50 if result.get("success"):
51 print_success(result.get("message", f"Executed: {path}"))
52 else:
53 print_error(result.get("message", f"Failed: {path}"))
54 raise typer.Exit(ExitCode.OPERATION_ERROR) from None
55 except UnityCLIError as e:
56 _handle_error(e)
57
58
59@menu_app.command("list")

Callers

nothing calls this directly

Calls 6

print_successFunction · 0.90
print_errorFunction · 0.90
_handle_errorFunction · 0.90
executeMethod · 0.80
ExitMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected