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

Function gameobject_active

unity_cli/cli/commands/gameobject.py:169–196  ·  view source on GitHub ↗

Enable or disable a GameObject (equivalent to the Inspector's top-left toggle). Use --no-active to disable. The default --active enables the object. Examples: u gameobject active -n HUD --no-active u gameobject active --id 12345 --active

(
    ctx: typer.Context,
    name: Annotated[str | None, typer.Option("--name", "-n", help="GameObject name")] = None,
    id: Annotated[int | None, typer.Option("--id", help="Instance ID")] = None,
    active: Annotated[
        bool,
        typer.Option("--active/--no-active", help="Set active (true) or inactive (false)"),
    ] = True,
)

Source from the content-addressed store, hash-verified

167@gameobject_app.command("active")
168@handle_cli_errors
169def gameobject_active(
170 ctx: typer.Context,
171 name: Annotated[str | None, typer.Option("--name", "-n", help="GameObject name")] = None,
172 id: Annotated[int | None, typer.Option("--id", help="Instance ID")] = None,
173 active: Annotated[
174 bool,
175 typer.Option("--active/--no-active", help="Set active (true) or inactive (false)"),
176 ] = True,
177) -> None:
178 """Enable or disable a GameObject (equivalent to the Inspector's top-left toggle).
179
180 Use --no-active to disable. The default --active enables the object.
181
182 Examples:
183 u gameobject active -n HUD --no-active
184 u gameobject active --id 12345 --active
185 """
186 context: CLIContext = ctx.obj
187
188 if not name and id is None:
189 _exit_usage("--name or --id required", "u gameobject active")
190
191 result = context.client.gameobject.set_active(
192 active=active,
193 name=name,
194 instance_id=id,
195 )
196 print_success(result.get("message", f"Active set to {active}"))
197
198
199@gameobject_app.command("delete")

Callers

nothing calls this directly

Calls 4

_exit_usageFunction · 0.90
print_successFunction · 0.90
set_activeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected