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

Function gameobject_modify

unity_cli/cli/commands/gameobject.py:126–164  ·  view source on GitHub ↗

Update a GameObject's position, rotation, and/or scale. Only the Transform options you pass are modified; the rest stay unchanged. Rotation is Euler angles in degrees. Examples: u gameobject modify -n Player --position 1 0 -3 u gameobject modify --id 12345 --rotation 0

(
    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,
    position: Annotated[
        tuple[float, float, float] | None,
        typer.Option("--position", help="Position (X Y Z)"),
    ] = None,
    rotation: Annotated[
        tuple[float, float, float] | None,
        typer.Option("--rotation", help="Rotation (X Y Z)"),
    ] = None,
    scale: Annotated[
        tuple[float, float, float] | None,
        typer.Option("--scale", help="Scale (X Y Z)"),
    ] = None,
)

Source from the content-addressed store, hash-verified

124@gameobject_app.command("modify")
125@handle_cli_errors
126def gameobject_modify(
127 ctx: typer.Context,
128 name: Annotated[str | None, typer.Option("--name", "-n", help="GameObject name")] = None,
129 id: Annotated[int | None, typer.Option("--id", help="Instance ID")] = None,
130 position: Annotated[
131 tuple[float, float, float] | None,
132 typer.Option("--position", help="Position (X Y Z)"),
133 ] = None,
134 rotation: Annotated[
135 tuple[float, float, float] | None,
136 typer.Option("--rotation", help="Rotation (X Y Z)"),
137 ] = None,
138 scale: Annotated[
139 tuple[float, float, float] | None,
140 typer.Option("--scale", help="Scale (X Y Z)"),
141 ] = None,
142) -> None:
143 """Update a GameObject's position, rotation, and/or scale.
144
145 Only the Transform options you pass are modified; the rest stay unchanged.
146 Rotation is Euler angles in degrees.
147
148 Examples:
149 u gameobject modify -n Player --position 1 0 -3
150 u gameobject modify --id 12345 --rotation 0 90 0 --scale 2 2 2
151 """
152 context: CLIContext = ctx.obj
153
154 if not name and id is None:
155 _exit_usage("--name or --id required", "u gameobject modify")
156
157 result = context.client.gameobject.modify(
158 name=name,
159 instance_id=id,
160 position=list(position) if position else None,
161 rotation=list(rotation) if rotation else None,
162 scale=list(scale) if scale else None,
163 )
164 print_success(result.get("message", "Transform modified"))
165
166
167@gameobject_app.command("active")

Callers

nothing calls this directly

Calls 4

_exit_usageFunction · 0.90
print_successFunction · 0.90
modifyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected