Skip to content

Commit 05ec3d1

Browse files
authored
Revert "[Feature] New UI system (#829)"
This reverts commit 6ab1069.
1 parent 6ab1069 commit 05ec3d1

17 files changed

Lines changed: 884 additions & 3623 deletions

File tree

‎.claude/skills/unity-mcp-skill/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ uri="file:///full/path/to/file.cs"
158158
| **Editor** | `manage_editor`, `execute_menu_item`, `read_console` | Editor control |
159159
| **Testing** | `run_tests`, `get_test_job` | Unity Test Framework |
160160
| **Batch** | `batch_execute` | Parallel/bulk operations |
161-
| **UI** | `manage_ui`, `batch_execute` with `manage_gameobject` + `manage_components` | **UI Toolkit**: Use `manage_ui` to create UXML/USS files, attach UIDocument, inspect visual trees. **uGUI (Canvas)**: Use `batch_execute` for Canvas, Panel, Button, Text, Slider, Toggle, Input Field. **Read `mcpforunity://project/info` first** to detect uGUI/TMP/Input System/UI Toolkit availability. (see [UI workflows](references/workflows.md#ui-creation-workflows)) |
161+
| **UI** | `batch_execute` with `manage_gameobject` + `manage_components` | Canvas, Panel, Button, Text, Slider, Toggle, Input Field. **Read `mcpforunity://project/info` first** to detect uGUI/TMP/Input System availability. (see [UI workflows](references/workflows.md#ui-creation-workflows)) |
162162

163163
## Common Workflows
164164

‎.claude/skills/unity-mcp-skill/references/tools-reference.md‎

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Complete reference for all MCP tools. Each tool includes parameters, types, and
1212
- [Script Tools](#script-tools)
1313
- [Asset Tools](#asset-tools)
1414
- [Material & Shader Tools](#material--shader-tools)
15-
- [UI Tools](#ui-tools)
1615
- [Editor Control Tools](#editor-control-tools)
1716
- [Testing Tools](#testing-tools)
1817

@@ -36,12 +35,10 @@ Read `mcpforunity://project/info` to detect project capabilities before making a
3635
| `packages.ugui` | bool | `com.unity.ugui` installed (Canvas, Image, Button, etc.) |
3736
| `packages.textmeshpro` | bool | `com.unity.textmeshpro` installed (TMP_Text, TMP_InputField) |
3837
| `packages.inputsystem` | bool | `com.unity.inputsystem` installed (InputAction, PlayerInput) |
39-
| `packages.uiToolkit` | bool | Always `true` for Unity 2021.3+ (UIDocument, VisualElement, UXML/USS) |
40-
| `packages.screenCapture` | bool | `com.unity.modules.screencapture` enabled (ScreenCapture API for screenshots) |
4138

4239
**Key decision points:**
4340

44-
- **UI system**: If `packages.uiToolkit` is true (always for Unity 2021+), use `manage_ui` for UI Toolkit workflows (UXML/USS). If `packages.ugui` is true, use Canvas + uGUI components via `batch_execute`. UI Toolkit is preferred for new UI — it uses a frontend-like workflow (UXML for structure, USS for styling).
41+
- **UI system**: If `packages.ugui` is true, use Canvas + uGUI components. UI Toolkit (UIDocument/UXML) is built-in since Unity 2021+ but has no MCP tool support yet.
4542
- **Text**: If `packages.textmeshpro` is true, use `TextMeshProUGUI` instead of legacy `Text`.
4643
- **Input**: Use `activeInputHandler` to decide EventSystem module — `StandaloneInputModule` (Old) vs `InputSystemUIInputModule` (New). See [workflows.md — Input System](workflows.md#input-system-old-vs-new).
4744
- **Shaders**: Use `renderPipeline` to pick correct shader names — `Standard` (BuiltIn) vs `Universal Render Pipeline/Lit` (URP) vs `HDRP/Lit` (HDRP).
@@ -586,76 +583,6 @@ manage_texture(
586583

587584
---
588585

589-
## UI Tools
590-
591-
### manage_ui
592-
593-
Manage Unity UI Toolkit elements: UXML documents, USS stylesheets, UIDocument components, and visual tree inspection.
594-
595-
```python
596-
# Create a UXML file
597-
manage_ui(
598-
action="create",
599-
path="Assets/UI/MainMenu.uxml",
600-
contents='<ui:UXML xmlns:ui="UnityEngine.UIElements"><ui:Label text="Hello" /></ui:UXML>'
601-
)
602-
603-
# Create a USS stylesheet
604-
manage_ui(
605-
action="create",
606-
path="Assets/UI/Styles.uss",
607-
contents=".title { font-size: 32px; color: white; }"
608-
)
609-
610-
# Read a UXML/USS file
611-
manage_ui(
612-
action="read",
613-
path="Assets/UI/MainMenu.uxml"
614-
)
615-
# Returns: {"success": true, "data": {"contents": "...", "path": "..."}}
616-
617-
# Update an existing file
618-
manage_ui(
619-
action="update",
620-
path="Assets/UI/Styles.uss",
621-
contents=".title { font-size: 48px; color: yellow; -unity-font-style: bold; }"
622-
)
623-
624-
# Attach UIDocument to a GameObject
625-
manage_ui(
626-
action="attach_ui_document",
627-
target="UICanvas", # GameObject name or path
628-
source_asset="Assets/UI/MainMenu.uxml",
629-
panel_settings="Assets/UI/Panel.asset", # optional, auto-creates if omitted
630-
sort_order=0 # optional, default 0
631-
)
632-
633-
# Create PanelSettings asset
634-
manage_ui(
635-
action="create_panel_settings",
636-
path="Assets/UI/Panel.asset",
637-
scale_mode="ScaleWithScreenSize", # optional: "ConstantPixelSize"|"ConstantPhysicalSize"|"ScaleWithScreenSize"
638-
reference_resolution={"width": 1920, "height": 1080} # optional, for ScaleWithScreenSize
639-
)
640-
641-
# Inspect the visual tree of a UIDocument
642-
manage_ui(
643-
action="get_visual_tree",
644-
target="UICanvas", # GameObject with UIDocument
645-
max_depth=10 # optional, default 10
646-
)
647-
# Returns: hierarchy of VisualElements with type, name, classes, styles, text, children
648-
```
649-
650-
**UI Toolkit workflow:**
651-
652-
1. Create UXML (structure, like HTML) and USS (styling, like CSS) files
653-
2. Create a PanelSettings asset (or let `attach_ui_document` auto-create one)
654-
3. Create an empty GameObject and attach UIDocument with the UXML source
655-
4. Use `get_visual_tree` to inspect the result
656-
657-
---
658-
659586
## Editor Control Tools
660587

661588
### manage_editor

‎.claude/skills/unity-mcp-skill/references/workflows.md‎

Lines changed: 6 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ manage_scene(action="screenshot")
561561

562562
## UI Creation Workflows
563563

564-
Unity has two UI systems: **UI Toolkit** (modern, recommended) and **uGUI** (Canvas-based, legacy). Use `manage_ui` for UI Toolkit workflows, and `batch_execute` with `manage_gameobject` + `manage_components` for uGUI.
564+
Unity UI (Canvas-based UGUI) requires specific component hierarchies. Use `batch_execute` with `fail_fast=True` to create complete UI elements in a single call.
565565

566566
> **Template warning:** This section is a skill template library, not a guaranteed source of truth. Examples may be inaccurate for your Unity version, package setup, or project conventions.
567567
> **Use safely:**
@@ -582,9 +582,7 @@ Unity has two UI systems: **UI Toolkit** (modern, recommended) and **uGUI** (Can
582582
# "packages": {
583583
# "ugui": true/false, — com.unity.ugui (Canvas, Image, Button, etc.)
584584
# "textmeshpro": true/false, — com.unity.textmeshpro (TextMeshProUGUI)
585-
# "inputsystem": true/false, — com.unity.inputsystem (new Input System)
586-
# "uiToolkit": true/false, — UI Toolkit (always true for Unity 2021.3+)
587-
# "screenCapture": true/false — ScreenCapture module enabled
585+
# "inputsystem": true/false — com.unity.inputsystem (new Input System)
588586
# }
589587
# }
590588
```
@@ -593,116 +591,13 @@ Unity has two UI systems: **UI Toolkit** (modern, recommended) and **uGUI** (Can
593591

594592
| project_info field | Value | What to use |
595593
|---|---|---|
596-
| `packages.uiToolkit` | `true` | **Preferred:** Use `manage_ui` for UI Toolkit (UXML/USS) |
597-
| `packages.ugui` | `true` | Canvas-based UI (Image, Button, etc.) via `batch_execute` |
598-
| `packages.textmeshpro` | `true` | `TextMeshProUGUI` for text (uGUI) |
594+
| `packages.ugui` | `true` | Canvas-based UI (Image, Button, etc.) |
595+
| `packages.textmeshpro` | `true` | `TextMeshProUGUI` for text |
599596
| `packages.textmeshpro` | `false` | `UnityEngine.UI.Text` (legacy, lower quality) |
600-
| `activeInputHandler` | `"Old"` | `StandaloneInputModule` for EventSystem (uGUI) |
601-
| `activeInputHandler` | `"New"` | `InputSystemUIInputModule` for EventSystem (uGUI) |
597+
| `activeInputHandler` | `"Old"` | `StandaloneInputModule` for EventSystem |
598+
| `activeInputHandler` | `"New"` | `InputSystemUIInputModule` for EventSystem |
602599
| `activeInputHandler` | `"Both"` | Either works; prefer `InputSystemUIInputModule` for UI |
603600

604-
### UI Toolkit Workflows (manage_ui)
605-
606-
UI Toolkit uses a web-like approach: **UXML** (like HTML) for structure, **USS** (like CSS) for styling. This is the preferred UI system for new projects.
607-
608-
#### Create a Complete UI Screen
609-
610-
```python
611-
# 1. Create UXML document (structure)
612-
manage_ui(
613-
action="create",
614-
path="Assets/UI/MainMenu.uxml",
615-
contents='''<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
616-
<ui:Style src="Assets/UI/MainMenu.uss" />
617-
<ui:VisualElement name="root" class="root-container">
618-
<ui:Label text="My Game" class="title" />
619-
<ui:Button text="Play" name="play-btn" class="menu-button" />
620-
<ui:Button text="Settings" name="settings-btn" class="menu-button" />
621-
<ui:Button text="Quit" name="quit-btn" class="menu-button" />
622-
</ui:VisualElement>
623-
</ui:UXML>'''
624-
)
625-
626-
# 2. Create USS stylesheet (styling)
627-
manage_ui(
628-
action="create",
629-
path="Assets/UI/MainMenu.uss",
630-
contents='''.root-container {
631-
flex-grow: 1;
632-
justify-content: center;
633-
align-items: center;
634-
background-color: rgba(0, 0, 0, 0.8);
635-
}
636-
.title {
637-
font-size: 48px;
638-
color: white;
639-
-unity-font-style: bold;
640-
margin-bottom: 40px;
641-
}
642-
.menu-button {
643-
width: 300px;
644-
height: 60px;
645-
font-size: 24px;
646-
margin: 8px;
647-
background-color: rgb(50, 120, 200);
648-
color: white;
649-
border-radius: 8px;
650-
}
651-
.menu-button:hover {
652-
background-color: rgb(70, 140, 220);
653-
}'''
654-
)
655-
656-
# 3. Create a GameObject and attach UIDocument
657-
manage_gameobject(action="create", name="UIRoot")
658-
manage_ui(
659-
action="attach_ui_document",
660-
target="UIRoot",
661-
source_asset="Assets/UI/MainMenu.uxml"
662-
# panel_settings auto-created if omitted
663-
)
664-
665-
# 4. Verify the visual tree
666-
manage_ui(action="get_visual_tree", target="UIRoot", max_depth=5)
667-
```
668-
669-
#### Update Existing UI
670-
671-
```python
672-
# Read current content
673-
result = manage_ui(action="read", path="Assets/UI/MainMenu.uss")
674-
# Modify and update
675-
manage_ui(
676-
action="update",
677-
path="Assets/UI/MainMenu.uss",
678-
contents=".title { font-size: 64px; color: yellow; }"
679-
)
680-
```
681-
682-
#### Custom PanelSettings
683-
684-
```python
685-
# Create PanelSettings with ScaleWithScreenSize
686-
manage_ui(
687-
action="create_panel_settings",
688-
path="Assets/UI/GamePanelSettings.asset",
689-
scale_mode="ScaleWithScreenSize",
690-
reference_resolution={"width": 1920, "height": 1080}
691-
)
692-
693-
# Attach UIDocument with custom PanelSettings
694-
manage_ui(
695-
action="attach_ui_document",
696-
target="UIRoot",
697-
source_asset="Assets/UI/MainMenu.uxml",
698-
panel_settings="Assets/UI/GamePanelSettings.asset"
699-
)
700-
```
701-
702-
### uGUI (Canvas-Based) Workflows
703-
704-
The sections below cover legacy Canvas-based UI using `batch_execute`. Use these when working with existing uGUI projects or when UI Toolkit is not suitable.
705-
706601
### RectTransform Sizing (Critical for All UI Children)
707602

708603
Every GameObject under a Canvas gets a `RectTransform` instead of `Transform`. **Without setting anchor/size, UI elements default to zero size and won't be visible.** Use `set_property` on `RectTransform`:

‎MCPForUnity/Editor/Resources/Project/ProjectInfo.cs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public static object HandleCommand(JObject @params)
3737
ugui = IsPackageInstalled("com.unity.ugui"),
3838
textmeshpro = IsPackageInstalled("com.unity.textmeshpro"),
3939
inputsystem = IsPackageInstalled("com.unity.inputsystem"),
40-
uiToolkit = true,
41-
screenCapture = MCPForUnity.Runtime.Helpers.ScreenshotUtility.IsScreenCaptureModuleAvailable,
4240
}
4341
};
4442

0 commit comments

Comments
 (0)