ui_source
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.registry.capability_adapter
Maturity: stable (support status; independent of enabled state, readiness and permissions).
Description
Create, read or edit UXML/USS assets, link stylesheets or preview source patches.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
action | Literal['create', 'read', 'update', 'delete', 'link_stylesheet', 'list', 'patch_source'] | yes | Feature action to perform. |
path | str | 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. |
contents | str | None | — | File content (UXML or USS markup). Plain text - encoding handled automatically. |
source_selector | str | None | — | patch_source: unique UXML #name, or exact simple USS type/.class/#name rule. |
source_changes | dict[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. |
preview | bool | — | patch_source: true (default) returns SHA256 and exact value edits without writing. False persists source and reimports; live view refresh is separate. |
expected_source_hash | str | None | — | patch_source apply requires source_hash from preview. Detects changed source before write. UTF8 files <=1 MiB; preserves BOM, surrounding bytes and .meta. |
verify_target | str | 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_type | Literal['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. |
stylesheet | str | None | — | Path to USS stylesheet to link (e.g., 'Assets/UI/Styles.uss'). For link_stylesheet. |
filter_type | str | None | — | Filter UI assets by type: 'uxml', 'uss', 'PanelSettings', or omit for all. For list. |
page_size | int | None | — | Number of results per page: 1-1000 (default 50). For list. |
page_number | int | None | — | Page number, 1-based (default 1). For list. |
inventory_revision | str | 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. |
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
Find the first 20 UXML documents before choosing a file to inspect or edit.
MCP arguments
{
"action": "list",
"filter_type": "uxml",
"page_size": 20,
"page_number": 1
}