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

Function component_inspect

unity_cli/cli/commands/component.py:54–82  ·  view source on GitHub ↗

Dump all serialized property values of a Component on a GameObject. Example: u component inspect -t "Main Camera" -T Camera

(
    ctx: typer.Context,
    component_type: Annotated[str, typer.Option("--type", "-T", help="Component type name")],
    target: Annotated[str | None, typer.Option("--target", "-t", help="Target GameObject name")] = None,
    target_id: Annotated[int | None, typer.Option("--target-id", help="Target GameObject ID")] = None,
    json_flag: Annotated[
        bool,
        typer.Option("--json", help="Output as JSON"),
    ] = False,
)

Source from the content-addressed store, hash-verified

52@component_app.command("inspect")
53@handle_cli_errors
54def component_inspect(
55 ctx: typer.Context,
56 component_type: Annotated[str, typer.Option("--type", "-T", help="Component type name")],
57 target: Annotated[str | None, typer.Option("--target", "-t", help="Target GameObject name")] = None,
58 target_id: Annotated[int | None, typer.Option("--target-id", help="Target GameObject ID")] = None,
59 json_flag: Annotated[
60 bool,
61 typer.Option("--json", help="Output as JSON"),
62 ] = False,
63) -> None:
64 """Dump all serialized property values of a Component on a GameObject.
65
66 Example:
67 u component inspect -t "Main Camera" -T Camera
68 """
69 context: CLIContext = ctx.obj
70
71 if not target and target_id is None:
72 _exit_usage("--target or --target-id required", "u component inspect")
73
74 result = context.client.component.inspect(
75 target=target,
76 target_id=target_id,
77 component_type=component_type,
78 )
79 if _should_json(context, json_flag):
80 print_json(result, None)
81 else:
82 print_key_value(result, component_type)
83
84
85@component_app.command("add")

Callers

nothing calls this directly

Calls 5

_exit_usageFunction · 0.90
_should_jsonFunction · 0.90
print_jsonFunction · 0.90
print_key_valueFunction · 0.90
inspectMethod · 0.45

Tested by

no test coverage detected