manage_ugui
Auto-generated from the Python tool registry. Do not hand-edit outside
<!-- examples:start --><!-- examples:end -->blocks — the generator (tools/generate_docs_reference.py) will overwrite them.
Group: ui · Module: services.tools.manage_ugui
Maturity: stable (support status; independent of enabled state, readiness and permissions).
Description
Inspect and edit Canvas-based uGUI hierarchies, RectTransforms, layout, text and CanvasScaler settings. Read-only actions: ping, get_hierarchy, diagnose, diagnose_projection, diagnose_text, diagnose_raycast with allow_custom_filters=false, diagnose_device_profiles. Mutating actions: create, set_rect, set_layout, set_text, set_canvas, set_image. Optional uGUI and TextMeshPro support is detected in the Editor. Writes include bounded data.verification for the same target, with retained serialized fields and current UI observations. Layout remains pending until normal updates; verification never rebuilds or captures. diagnose evaluates bounded Overlay screen-size candidates. diagnose_projection reads current mono camera geometry for Screen Camera/World Space without rendering or forcing layout; it is not rendered visibility. diagnose_text observes existing generated TMP layout only; dirty/uninitialized data is unknown, with no rebuild or hypothetical sizes. diagnose_raycast inspects pointer hit order and raycast occlusion at screen_position [x,y] in Game View pixels from the bottom left. Supply a scene UI GameObject with a RectTransform as target to compare its handler with the first hit. No click is sent. An unknown result provides no confirmed hit order. Even a known hit order does not establish event receipt. Custom filters are refused by default; explicit allow_custom_filters may run user code without rollback or a hard deadline. diagnose_device_profiles assesses 1..8 explicit virtual/observed profiles: built-in-only owned Overlay preview or same-resolution current camera geometry, with DPI/safe-area provenance and caller touch thresholds. The package dispatches no pointer/selection events or explicit source edits.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
action | Literal['ping', 'get_hierarchy', 'create', 'create_control', 'set_rect', 'set_layout', 'set_text', 'set_canvas', 'set_image', 'diagnose', 'diagnose_projection', 'diagnose_text', 'diagnose_raycast', 'diagnose_device_profiles'] | yes | Action to perform. |
target | str | int | None | — | GameObject name, hierarchy path, or instance ID. Required for get_hierarchy, setters and diagnose. For diagnose_raycast select a scene UI GameObject with a RectTransform. |
parent | str | int | None | — | Parent GameObject for create, resolved by name, hierarchy path, or instance ID. |
name | str | None | — | Name of the created GameObject. |
element_type | Literal['canvas', 'panel', 'image', 'button', 'text', 'scroll_view', 'toggle', 'slider', 'tmp_input'] | None | — | Element to create: canvas, panel, image, button, or text. |
properties | dict[str, JsonValue] | str | None | — | Action-specific camelCase properties, as a dict or JSON object string. Rect: anchorMin, anchorMax, pivot, anchoredPosition, sizeDelta, offsetMin, offsetMax, localScale, localEulerAngles. Create: all elements accept Rect properties; panel/image/button also accept color; text also accepts Text properties. set_image edits an existing Image: sprite=null/path/{path,name}, type, fillMethod, fillOrigin, fillAmount, fillClockwise, preserveAspect, fillCenter, color and raycastTarget. Fill fields require final Filled type; origin is validated against final fillMethod. Sliced requires a bordered base sprite. No importer edit, explicit import/refresh or component creation occurs. Layout: type must be vertical, horizontal, grid, layout_element or content_size_fitter, plus that component's properties. Text: text, fontSize, color, alignment, enableAutoSizing, fontSizeMin, fontSizeMax, raycastTarget. Canvas: Canvas and CanvasScaler properties via set_canvas. |
include_inactive | bool | — | Include inactive GameObjects in hierarchy and diagnostics. |
max_nodes | int | — | Maximum hierarchy nodes to inspect, 1 to 1000. |
camera | str | int | None | — | For diagnose_projection: explicit view camera required for World Space; Screen Camera uses only its assigned camera. Current scene GameObject name/path/Int32 ID; no camera fallback. |
max_depth | int | None | — | For diagnose_projection or diagnose_text: physical transform depth; for diagnose_raycast: filter ancestry only. Default 10, range 0..24. |
max_evaluations | int | None | — | For diagnose_projection, diagnose_text or diagnose_raycast: shared precharged package work, default 20000, range 1..200000. Raycast includes selector/handler work; native callbacks have no hard deadline. |
max_characters | int | None | — | For diagnose_projection, diagnose_text or diagnose_raycast: shared output metadata UTF-16 budget, default 65536, range 1..262144. |
resolutions | list[dict[str, int]] | str | None | — | For diagnose: 1 to 8 {width,height} objects, or a JSON array string. Integer dimensions 64 to 8192. Omit to use Editor diagnostic defaults. |
device_profiles | list[VirtualProfile | ObservedProfile] | None | — | For diagnose_device_profiles: 1..8 closed records. Virtual requires source,width,height,dpi,safe_area=[x,y,width,height] in bottom-left pixels and concrete orientation; observed accepts source only. |
minimum_touch_target_mm | float | None | — | For diagnose_device_profiles only: explicit caller threshold in millimetres; no universal threshold is assumed. |
screen_position | list[float] | None | — | For diagnose_raycast: required [x,y] in current-screen pixels from the bottom-left; no camera/resolution edit. |
allow_custom_filters | bool | — | For diagnose_raycast only: explicitly permit native ICanvasRaycastFilter user code. Default false refuses before applicable custom callbacks; opt-in is not transactional or interruptible. |
strict_read | bool | — | For diagnose_raycast, require native read-only preflight and a matching policy receipt. |
unity_instance | str | int | None | — | Target Unity instance for this call: Name@hash or hash prefix; an integer selects only that exact port over stdio and is rejected over HTTP. Read mcpforunity://instances for available targets. Omit to use the legacy active selection or the sole available instance. |
Returns
A dict containing the Unity response. The exact shape depends on the action.
Examples
Inspect a Canvas hierarchy, including inactive elements:
{"action":"get_hierarchy","target":"MainCanvas","include_inactive":true,"max_nodes":200}
Create a Canvas and a TMP label (the label needs TextMeshPro and a default font asset):
{"action":"create","element_type":"canvas","name":"MainCanvas"}
{"action":"create","element_type":"text","parent":"MainCanvas","name":"Title","properties":{"text":"Main menu","fontSize":32,"sizeDelta":[480,64]}}
Set a RectTransform and configure a layout group:
{"action":"set_rect","target":"MainCanvas/Title","properties":{"anchorMin":[0.5,1],"anchorMax":[0.5,1],"pivot":[0.5,1],"anchoredPosition":[0,-16],"sizeDelta":[480,64]}}
{"action":"set_layout","target":"MainCanvas","properties":{"type":"vertical","spacing":12,"childControlHeight":false,"childForceExpandHeight":false}}
Change text and CanvasScaler settings:
{"action":"set_text","target":"MainCanvas/Title","properties":{"text":"Choose a level","fontSize":28,"raycastTarget":false}}
{"action":"set_canvas","target":"MainCanvas","properties":{"uiScaleMode":"ScaleWithScreenSize","referenceResolution":[1920,1080],"matchWidthOrHeight":0.5}}
Evaluate Screen Space Overlay layout candidates at two screen sizes:
{"action":"diagnose","target":"MainCanvas","resolutions":[{"width":1920,"height":1080},{"width":1080,"height":1920}],"max_nodes":200}
Check report truncation and limitations. Findings are preview candidates, not screenshots or confirmed runtime input failures. See the uGUI guide for component properties, dependencies and diagnostic scope, and Tool groups for visibility.