Unity CLI - Control a running Unity Editor from the shell or scripts. Sends commands to the Unity Editor via a local Relay Server (TCP:6500). Lets you: enter/exit play mode, refresh assets, read console logs, run tests, create/modify GameObjects and Components, execute menu items (inclu
(
ctx: typer.Context,
relay_host: Annotated[
str | None,
typer.Option(
"--relay-host",
help="Relay server host",
envvar="UNITY_RELAY_HOST",
),
] = None,
relay_port: Annotated[
int | None,
typer.Option(
"--relay-port",
help="Relay server port",
envvar="UNITY_RELAY_PORT",
),
] = None,
instance: Annotated[
str | None,
typer.Option(
"--instance",
"-i",
help="Target Unity instance (path, project name, or prefix)",
envvar="UNITY_INSTANCE",
),
] = None,
timeout: Annotated[
float | None,
typer.Option(
"--timeout",
"-t",
help="Timeout in seconds",
),
] = None,
pretty_flag: Annotated[
bool | None,
typer.Option(
"--pretty/--no-pretty",
help="Force pretty or plain output",
),
] = None,
quiet: Annotated[
bool,
typer.Option(
"--quiet",
"-q",
help="Suppress success messages (errors still go to stderr)",
envvar="UNITY_CLI_QUIET",
),
] = False,
verbose: Annotated[
bool,
typer.Option(
"--verbose",
help="Show request/response on stderr",
envvar="UNITY_CLI_VERBOSE",
),
] = False,
)
| 84 | |
| 85 | @app.callback() |
| 86 | def main( |
| 87 | ctx: typer.Context, |
| 88 | relay_host: Annotated[ |
| 89 | str | None, |
| 90 | typer.Option( |
| 91 | "--relay-host", |
| 92 | help="Relay server host", |
| 93 | envvar="UNITY_RELAY_HOST", |
| 94 | ), |
| 95 | ] = None, |
| 96 | relay_port: Annotated[ |
| 97 | int | None, |
| 98 | typer.Option( |
| 99 | "--relay-port", |
| 100 | help="Relay server port", |
| 101 | envvar="UNITY_RELAY_PORT", |
| 102 | ), |
| 103 | ] = None, |
| 104 | instance: Annotated[ |
| 105 | str | None, |
| 106 | typer.Option( |
| 107 | "--instance", |
| 108 | "-i", |
| 109 | help="Target Unity instance (path, project name, or prefix)", |
| 110 | envvar="UNITY_INSTANCE", |
| 111 | ), |
| 112 | ] = None, |
| 113 | timeout: Annotated[ |
| 114 | float | None, |
| 115 | typer.Option( |
| 116 | "--timeout", |
| 117 | "-t", |
| 118 | help="Timeout in seconds", |
| 119 | ), |
| 120 | ] = None, |
| 121 | pretty_flag: Annotated[ |
| 122 | bool | None, |
| 123 | typer.Option( |
| 124 | "--pretty/--no-pretty", |
| 125 | help="Force pretty or plain output", |
| 126 | ), |
| 127 | ] = None, |
| 128 | quiet: Annotated[ |
| 129 | bool, |
| 130 | typer.Option( |
| 131 | "--quiet", |
| 132 | "-q", |
| 133 | help="Suppress success messages (errors still go to stderr)", |
| 134 | envvar="UNITY_CLI_QUIET", |
| 135 | ), |
| 136 | ] = False, |
| 137 | verbose: Annotated[ |
| 138 | bool, |
| 139 | typer.Option( |
| 140 | "--verbose", |
| 141 | help="Show request/response on stderr", |
| 142 | envvar="UNITY_CLI_VERBOSE", |
| 143 | ), |
nothing calls this directly
no test coverage detected