Skip to main content

manage_ui

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: legacy  ·  Module: services.tools.manage_ui

Maturity: stable (support status; independent of enabled state, readiness and permissions).

Description​

Manages Unity UI Toolkit elements (UXML, USS, UIDocument and supported PanelRenderer components). Read actions: ping, read, diagnose, list. get_visual_tree can invoke project-defined getters and requires read, edit and run authority. Modifying actions: create, update, delete, attach_ui_document, detach_ui_document, create_panel_settings, update_panel_settings, modify_visual_element. diagnose observes bounded current-panel physical geometry/clipping/overflow/sibling-overlap candidates without text or layout updates. Unknown/partial results are not a clean-layout assertion; diagnostic paths are not mutation/snapshot selectors. Visual actions: render_ui (captures UI panel to a PNG screenshot for self-evaluation). Structural actions: link_stylesheet (adds a Style src reference to a UXML file). patch_source previews narrow existing source attribute/declaration edits; preview=false requires expected_source_hash and persists source separately from live UI.

Inspect existing assets and the live visual tree before choosing source edits or runtime changes. Create, attach, detach or delete only when required by the requested change; preserve unrelated UI. For attach_ui_document, component_type=auto preserves existing UIDocument and prefers available PanelRenderer for new objects; ui_document selects UIDocument. Explicit panel_renderer selection requires the Editor's native PanelRenderer API. modify_visual_element changes live text/classes/styles, not persisted source. Legacy element_name selects the first match; strict_name=true requires uniqueness. Writes include bounded data.verification from the resolved target; current layout can remain pending. Source writes only inspect live UI when verify_target explicitly selects a document before the write. element_path selects current child indices; element_id selects a snapshot identity. Explicit selectors do not fall back to names. For render_ui, Play Mode queues end-of-frame capture and returns pending=true. Resume with its capture_id; cancel with that ID and cancel_capture=true. ID-less calls start new requests; another live owner is rejected. Edit-mode readback is best-effort; warmup_updates=1..4 enables bounded deferred readback with capture_id. Inspect returned images and readiness; full-image alpha occupancy does not establish UI presence. Use namespace-qualified ui:Style elements for stylesheet links so UI Builder can read the UXML.

Parameters​

NameTypeRequiredDescription
actionLiteral['ping', 'create', 'read', 'update', 'delete', 'attach_ui_document', 'detach_ui_document', 'create_panel_settings', 'update_panel_settings', 'get_visual_tree', 'diagnose', 'render_ui', 'link_stylesheet', 'list', 'modify_visual_element', 'patch_source']yesAction to perform.
pathstr | None—Assets-relative path (e.g., 'Assets/UI/MainMenu.uxml' or 'Assets/UI/Styles.uss'). For render_ui: optional UXML path to render directly without a scene GameObject.
contentsstr | None—File content (UXML or USS markup). Plain text - encoding handled automatically.
source_selectorstr | None—patch_source: unique UXML #name, or exact simple USS type/.class/#name rule.
source_changesdict[str, str] | None—patch_source: 1..32 existing UXML text/tooltip/class attributes or USS declarations; values <=4096 characters. No insertion/removal or template ownership.
previewbool—patch_source: true (default) returns SHA256 and exact value edits without writing. False persists source and reimports; live view refresh is separate.
expected_source_hashstr | None—patch_source apply requires source_hash from preview. Detects changed source before write. UTF8 files <=1 MiB; preserves BOM, surrounding bytes and .meta.
targetstr | None—Target GameObject name or path for attach_ui_document / get_visual_tree / render_ui.
verify_targetstr | None—Optional exact live document target for create/update/link_stylesheet/patch_source writes. Resolved before saving; adds bounded current diagnostics without forcing layout or capture. Source-to-live application remains pending until normal UI updates.
component_typeLiteral['auto', 'ui_document', 'panel_renderer'] | None—UI component for attach/detach, get_visual_tree, modify_visual_element and render_ui. Default auto preserves an existing UIDocument, otherwise resolves PanelRenderer; new attachments prefer PanelRenderer when available and fall back to UIDocument. Explicit panel_renderer selection requires the Editor's native PanelRenderer API.
source_assetstr | None—Path to UXML VisualTreeAsset (e.g., 'Assets/UI/MainMenu.uxml').
panel_settingsstr | None—Path to PanelSettings asset. Auto-creates default if omitted.
sort_orderint | None—UI component sort order (default 0).
scale_modeLiteral['ConstantPixelSize', 'ConstantPhysicalSize', 'ScaleWithScreenSize'] | None—Panel scale mode. Legacy shorthand; prefer using 'settings' dict.
reference_resolutiondict[str, int] | None—Reference resolution as {width, height}. Legacy shorthand; prefer using 'settings' dict.
settingsdict[str, Any] | None—Generic PanelSettings properties dict for create_panel_settings. Keys: scaleMode (ConstantPixelSize|ConstantPhysicalSize|ScaleWithScreenSize), referenceResolution ({width,height}), screenMatchMode (MatchWidthOrHeight|ShrinkToFit|ExpandToFill), match (0-1 float), referenceDpi, fallbackDpi, sortingOrder, targetDisplay, clearColor (bool), colorClearValue (#RRGGBB or {r,g,b,a}), clearDepthStencil, themeStyleSheet (asset path), dynamicAtlasSettings ({minAtlasSize,maxAtlasSize,maxSubTextureSize,activeFilters}).
max_depthint | None—get_visual_tree / diagnose inclusive depth: root is 0; default 10, maximum 24.
max_nodesint | None—get_visual_tree / diagnose emitted node budget, including root (default 200).
max_evaluationsint | None—get_visual_tree operation budget: node admissions, child fetches and class probes; diagnose charges ancestors, admissions, child fetches, fixed style probes and pairs (default 5000). Not a time or scene-lookup bound.
max_charactersint | None—get_visual_tree / diagnose shared copied UTF-16 string budget including metadata (default 65536). get_visual_tree per-string limit 8192/class limit 64; diagnose name/type limit 256 and whole physical paths.
max_pairsint | None—diagnose physical sibling pairs examined before filters (default 2000); zero disables overlap and yields partial evidence.
max_findingsint | None—diagnose retained candidate findings (default 200); reaching the cap reports partial coverage.
capture_idstr | None—Deferred capture ID returned by render_ui. Supply this ID alone to poll the original request; optional target/output settings must match the start request. Omit to start a separate capture even with identical settings. Results expire after 30 seconds.
cancel_capturebool | None—Cancel the deferred capture owned by capture_id (default false). For render_ui.
warmup_updatesint | None—Edit-mode panel readback delay in Editor updates, 0 to 4 (default 0). Positive values return capture_id for polling/cancellation; no repaint guarantee or automatic retries. Play mode requires 0 and already captures at end of frame. For render_ui.
widthint | None—Render width in pixels, 1 to 8192 (default 1920). The frame may contain at most 33,554,432 pixels. For render_ui.
heightint | None—Render height in pixels, 1 to 8192 (default 1080). For render_ui.
include_imagebool | None—Return inline base64 PNG in the response (default false). For render_ui.
max_resolutionint | None—Max resolution for inline base64 image, 1 to 8192 (default 640; 0 selects the default). For render_ui.
screenshot_file_namestr | None—Custom file name for the render output (default: auto-generated). For render_ui.
output_folderstr | None—Optional folder for the render output. Project-relative (e.g. 'Assets/Screenshots' or 'Captures') or absolute path inside the project. Overrides the user's Editor preference. If omitted, falls back to the Editor preference, then to the built-in default (Assets/Screenshots). For render_ui.
stylesheetstr | None—Path to USS stylesheet to link (e.g., 'Assets/UI/Styles.uss'). For link_stylesheet.
filter_typestr | None—Filter UI assets by type: 'uxml', 'uss', 'PanelSettings', or omit for all. For list.
page_sizeint | None—Number of results per page: 1-1000 (default 50). For list.
page_numberint | None—Page number, 1-based (default 1). For list.
inventory_revisionstr | None—list: reuse the returned inventory_revision with the same scope/filter to reject pages after asset changes, expiry or eviction. Omit for the latest cached inventory; oversized inventories remain complete but uncached.
element_namestr | None—Visual element name. Legacy first match unless strict_name=true. Optional exact name guard with element_path or element_id. For modify_visual_element.
element_pathstr—Current snapshot/content-container child-index path, e.g. '/0/1'; empty string selects root. Zero-based decimal indices, no leading zeros. No persistent identity or replacement detection. Mutually exclusive with element_id; no name fallback. Omit when unused; explicit null is invalid.
element_idstr—Exact current UI Toolkit snapshot node ID. Uses the snapshot's auto-selected UI component; use element_path for another component_type. Semantic path, not a persistent handle; same-path replacement is not detected. No name fallback. Omit when unused; null/empty invalid.
strict_namebool | None—Require exactly one element_name match over the UQuery root and physical control internals. Default false keeps legacy first match. Active initialized UI required; bounded scan may refuse. Explicit selectors take precedence; element_name then guards the selected name.
textstr | None—New text content for Label/Button elements. For modify_visual_element.
add_classeslist[str] | None—USS class names to add to the element. For modify_visual_element.
remove_classeslist[str] | None—USS class names to remove from the element. For modify_visual_element.
toggle_classeslist[str] | None—USS class names to toggle on the element. For modify_visual_element.
styledict[str, Any] | None—Inline styles for modify_visual_element. Legacy scalar values remain supported. Typed lengths: {'value': 50, 'unit': '%'} or {'keyword': 'auto'} where supported. Inspect data.style_results for every applied/rejected entry and final inline overrides.
enabledbool | None—Set element enabled/disabled state. For modify_visual_element.
visiblebool | None—Set element visibility (display: flex/none). For modify_visual_element.
tooltipstr | None—Set element tooltip text. For modify_visual_element.
strict_stylebool—Reject every requested mutation before application if any inline style is rejected. Only modify_visual_element; default false preserves lenient compatibility. Validation is not callback rollback.
unity_instancestr | 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​

Check whether the selected Editor's UI Toolkit operations are ready before opening a UXML asset.

MCP arguments
{
"action": "ping"
}