Marcus/update readme on release (#607)

* chore: update version references in README files during release

- Add version update for root README.md UPM fixed version examples
- Add version update for README-zh.md UPM and pip fixed version examples
- Include README.md and README-zh.md in release commit

* Update version in README

* Update example command version

* Update simplified Chinese readme to match english one

* The readme has changed

* docs: reorganize documentation into structured subdirectories

- Move README-zh.md to docs/i18n/README-zh.md
- Move development docs to docs/development/ (README-DEV.md, README-DEV-zh.md)
- Move user guides to docs/guides/ (CLI_USAGE.md, CURSOR_HELP.md, MCP_CLIENT_CONFIGURATORS.md)
- Move migration guides to docs/migrations/ (v5_MIGRATION.md, v6_NEW_UI_CHANGES.md, v8_NEW_NETWORKING_SETUP.md)
- Move reference docs to docs/reference/ (CUSTOM_TOOLS.md, TELEMETRY.md)
- Update all internal links in README
main
Marcus Sanatan 2026-01-21 22:35:24 -04:00 committed by GitHub
parent 3ef2d37790
commit 9682e3c3e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 258 additions and 493 deletions

View File

@ -85,6 +85,12 @@ jobs:
echo "Updating Server/README.md version references to v$NEW_VERSION"
sed -i 's|git+https://github.com/CoplayDev/unity-mcp@v[0-9]\+\.[0-9]\+\.[0-9]\+#subdirectory=Server|git+https://github.com/CoplayDev/unity-mcp@v'"$NEW_VERSION"'#subdirectory=Server|g' Server/README.md
echo "Updating root README.md fixed version examples to v$NEW_VERSION"
sed -i 's|https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v[0-9]\+\.[0-9]\+\.[0-9]\+|https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v'"$NEW_VERSION"'|g' README.md
echo "Updating docs/i18n/README-zh.md fixed version examples to v$NEW_VERSION"
sed -i 's|https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v[0-9]\+\.[0-9]\+\.[0-9]\+|https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v'"$NEW_VERSION"'|g' docs/i18n/README-zh.md
- name: Commit and push changes
env:
NEW_VERSION: ${{ steps.compute.outputs.new_version }}
@ -93,7 +99,7 @@ jobs:
set -euo pipefail
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add MCPForUnity/package.json "Server/pyproject.toml" Server/README.md
git add MCPForUnity/package.json "Server/pyproject.toml" Server/README.md README.md docs/i18n/README-zh.md
if git diff --cached --quiet; then
echo "No version changes to commit."
else

View File

@ -1,488 +0,0 @@
<img width="676" height="380" alt="MCP for Unity" src="docs/images/logo.png" />
| [English](README.md) | [简体中文](README-zh.md) |
|----------------------|---------------------------------|
#### 由 [Coplay](https://www.coplay.dev/?ref=unity-mcp) 荣誉赞助和维护 -- Unity 最好的 AI 助手。
[![Discord](https://img.shields.io/badge/discord-join-red.svg?logo=discord&logoColor=white)](https://discord.gg/y4p8KfzrN4)
[![](https://img.shields.io/badge/Website-Visit-purple)](https://www.coplay.dev/?ref=unity-mcp)
[![](https://img.shields.io/badge/Unity-000000?style=flat&logo=unity&logoColor=blue 'Unity')](https://unity.com/releases/editor/archive)
[![Unity Asset Store](https://img.shields.io/badge/Unity%20Asset%20Store-Get%20Package-FF6A00?style=flat&logo=unity&logoColor=white)](https://assetstore.unity.com/packages/tools/generative-ai/mcp-for-unity-ai-driven-development-329908)
[![python](https://img.shields.io/badge/Python-3.10+-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
[![](https://badge.mcpx.dev?status=on 'MCP Enabled')](https://modelcontextprotocol.io/introduction)
![GitHub commit activity](https://img.shields.io/github/commit-activity/w/CoplayDev/unity-mcp)
![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/CoplayDev/unity-mcp)
[![](https://img.shields.io/badge/License-MIT-red.svg 'MIT License')](https://opensource.org/licenses/MIT)
**使用大语言模型创建您的 Unity 应用!**
MCP for Unity 作为桥梁,允许 AI 助手(如 Claude、Cursor通过本地 **MCP模型上下文协议客户端** 直接与您的 Unity 编辑器交互。为您的大语言模型提供管理资源、控制场景、编辑脚本和自动化 Unity 任务的工具。
<img alt="MCP for Unity building a scene" src="docs/images/building_scene.gif">
### 💬 加入我们的 [Discord](https://discord.gg/y4p8KfzrN4)
**获得帮助、分享想法,与其他 MCP for Unity 开发者协作!**
---
## 主要功能 🚀
* **🗣️ 自然语言操控:** 指示您的大语言模型执行 Unity 任务。
* **🛠️ 强大工具:** 管理资源、场景、材质、脚本和编辑器功能。
* **🤖 自动化:** 自动化重复的 Unity 工作流程。
* **🧩 可扩展:** 设计为与各种 MCP 客户端协作。
* **🌐 HTTP 优先传输:** 默认启用 HTTP 连接stdio 仍可作为备选方案)。
<details open>
<summary><strong>工具</strong></summary>
您的大语言模型可以使用以下功能:
* `manage_asset`: 执行资源操作(导入、创建、修改、删除、搜索等)。
* `manage_editor`: 控制编辑器状态(播放模式、活动工具、标签、层)。
* `manage_gameobject`: 管理 GameObject创建、修改、删除、查找、复制、移动
* `manage_components`: 管理 GameObject 上的组件(添加、移除、设置属性)。
* `manage_material`: 管理材质(创建、设置属性/颜色、分配给渲染器)。
* `manage_prefabs`: 预制体操作(打开/关闭 Stage、保存、从 GameObject 创建)。
* `manage_scene`: 场景管理(加载、保存、创建、获取层级、截图)。
* `manage_script`: 传统脚本操作(创建、读取、删除)。编辑建议使用 `apply_text_edits``script_apply_edits`
* `manage_scriptable_object`: 创建并修改 ScriptableObject 资产。
* `manage_shader`: Shader CRUD创建、读取、更新、删除
* `manage_vfx`: VFX 操作ParticleSystem / LineRenderer / TrailRenderer / VisualEffectGraph 等)。
* `batch_execute`: ⚡ **推荐** - 批量执行多条命令10-100x 性能提升)。
* `find_gameobjects`: 按 name/tag/layer/component/path/id 搜索 GameObject分页
* `find_in_file`: 使用正则搜索 C# 脚本并返回匹配的行号与片段。
* `read_console`: 获取或清除 Unity Console 日志。
* `refresh_unity`: 请求刷新资产数据库,并可选触发编译。
* `run_tests`: 异步启动测试,返回 job_id。
* `get_test_job`: 轮询异步测试任务的进度和结果。
* `debug_request_context`: 返回当前请求上下文client_id、session_id、meta
* `execute_custom_tool`: 执行由 Unity 注册的项目级自定义工具。
* `execute_menu_item`: 执行 Unity 编辑器菜单项(例如 "File/Save Project")。
* `set_active_instance`: 将后续工具调用路由到特定 Unity 实例(从 `unity_instances` 获取 `Name@hash`)。
* `apply_text_edits`: 使用行/列范围进行精确文本编辑(支持前置条件哈希)。
* `script_apply_edits`: 结构化 C# 方法/类编辑insert/replace/delete边界更安全。
* `validate_script`: 快速验证basic/standard用于捕获语法/结构问题。
* `create_script`: 在指定项目路径创建新的 C# 脚本。
* `delete_script`: 通过 URI 或 Assets 相对路径删除 C# 脚本。
* `get_sha`: 获取 Unity C# 脚本的 SHA256 与元数据(不返回内容)。
</details>
<details open>
<summary><strong>资源</strong></summary>
您的大语言模型可以检索以下资源:
* `custom_tools` [`mcpforunity://custom-tools`]: 列出活动 Unity 项目可用的自定义工具。
* `unity_instances` [`mcpforunity://instances`]: 列出所有正在运行的 Unity 编辑器实例及其详细信息。
* `menu_items` [`mcpforunity://menu-items`]: Unity 编辑器中所有可用菜单项。
* `get_tests` [`mcpforunity://tests`]: Unity 编辑器中所有可用测试EditMode + PlayMode
* `get_tests_for_mode` [`mcpforunity://tests/{mode}`]: 指定模式EditMode 或 PlayMode的测试列表。
* `gameobject_api` [`mcpforunity://scene/gameobject-api`]: GameObject 资源用法说明(先用 `find_gameobjects` 获取 instance ID
* `gameobject` [`mcpforunity://scene/gameobject/{instance_id}`]: 读取单个 GameObject 信息(不含完整组件序列化)。
* `gameobject_components` [`mcpforunity://scene/gameobject/{instance_id}/components`]: 读取某 GameObject 的全部组件(支持分页,可选包含属性)。
* `gameobject_component` [`mcpforunity://scene/gameobject/{instance_id}/component/{component_name}`]: 读取某 GameObject 上指定组件的完整属性。
* `editor_active_tool` [`mcpforunity://editor/active-tool`]: 当前活动工具Move/Rotate/Scale 等)与变换手柄设置。
* `editor_prefab_stage` [`mcpforunity://editor/prefab-stage`]: 当前 Prefab Stage 上下文(若未打开则 isOpen=false
* `editor_selection` [`mcpforunity://editor/selection`]: 编辑器当前选中对象的详细信息。
* `editor_state` [`mcpforunity://editor/state`]: 编辑器就绪状态快照(包含建议与 staleness
* `editor_windows` [`mcpforunity://editor/windows`]: 当前打开的编辑器窗口列表(标题、类型、位置、焦点)。
* `project_info` [`mcpforunity://project/info`]: 静态项目信息根路径、Unity 版本、平台)。
* `project_layers` [`mcpforunity://project/layers`]: 项目层0-31及名称。
* `project_tags` [`mcpforunity://project/tags`]: 项目 Tag 列表。
</details>
---
## 工作原理
MCP for Unity 使用两个组件连接您的工具:
1. **MCP for Unity Bridge** 在编辑器内运行的 Unity 包。(通过包管理器安装)。
2. **MCP for Unity Server** 本地运行的 Python 服务器(从终端窗口运行),通过 HTTP/JSON-RPC 与您的 MCP 客户端通信。Unity 窗口默认以 HTTP 模式为您启动它如果您切换传输方式stdio 仍然可用。
<img width="562" height="121" alt="image" src="https://github.com/user-attachments/assets/9abf9c66-70d1-4b82-9587-658e0d45dc3e" />
---
## 安装 ⚙️
### 前置要求
如果你**不是**通过 Unity Asset Store 安装,则还需要安装以下内容:
* **Python** 版本 3.10 或更新。[下载 Python](https://www.python.org/downloads/)
* **uvPython 工具链管理器):**
```bash
# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
winget install --id=astral-sh.uv -e
# 文档: https://docs.astral.sh/uv/getting-started/installation/
```
所有安装方式都需要以下内容:
* **Unity Hub 和编辑器:** 版本 2021.3 LTS 或更新。[下载 Unity](https://unity.com/download)
* **MCP 客户端:** [Claude Desktop](https://claude.ai/download) | [Claude Code](https://github.com/anthropics/claude-code) | [Cursor](https://www.cursor.com/en/downloads) | [Visual Studio Code Copilot](https://code.visualstudio.com/docs/copilot/overview) | [Windsurf](https://windsurf.com) | 其他客户端可通过手动配置使用
<details> <summary><strong>[可选] Roslyn 用于高级脚本验证</strong></summary>
对于捕获未定义命名空间、类型和方法的**严格**验证级别:
**方法 1Unity 的 NuGet推荐**
1. 安装 [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity)
2. 前往 `Window > NuGet Package Manager`
3. 搜索 `Microsoft.CodeAnalysis`,选择版本 4.14.0 并安装包
4. 同时安装包 `SQLitePCLRaw.core``SQLitePCLRaw.bundle_e_sqlite3`
5. 前往 `Player Settings > Scripting Define Symbols`
6. 添加 `USE_ROSLYN`
7. 重启 Unity
**方法 2手动 DLL 安装**
1. 从 [NuGet](https://www.nuget.org/packages/Microsoft.CodeAnalysis.CSharp/) 下载 Microsoft.CodeAnalysis.CSharp.dll 和依赖项
2. 将 DLL 放置在 `Assets/Plugins/` 文件夹中
3. 确保 .NET 兼容性设置正确
4. 将 `USE_ROSLYN` 添加到脚本定义符号
5. 重启 Unity
**注意:** 没有 Roslyn 时脚本验证会回退到基本结构检查。Roslyn 启用完整的 C# 编译器诊断和精确错误报告。</details>
---
### 🌟 步骤 1安装 Unity 包
#### 通过 Unity Asset Store 安装
1. 在浏览器中打开https://assetstore.unity.com/packages/tools/generative-ai/mcp-for-unity-ai-driven-development-329908
2. 点击 `Add to My Assets`
3. 在 Unity 编辑器中,前往 `Window > Package Manager`
4. 将该资源下载并导入到你的项目中
#### 通过 Git URL 安装
1. 打开您的 Unity 项目。
2. 前往 `Window > Package Manager`
3. 点击 `+` -> `Add package from git URL...`
4. 输入:
```
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity
```
5. 点击 `Add`
**需要锁定版本?** 使用带标签的 URL更新时需卸载并重新安装
```
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v8.6.0
```
#### 通过 OpenUPM 安装
1. 安装 [OpenUPM CLI](https://openupm.com/docs/getting-started-cli.html)
2. 打开终端PowerShell、Terminal 等)并导航到您的 Unity 项目目录
3. 运行 `openupm add com.coplaydev.unity-mcp`
**注意:** 如果您在 Coplay 维护之前安装了 MCP 服务器,您需要在重新安装新版本之前卸载旧包。
### ⚡️ 步骤 2启动本地 HTTP 服务器(默认)
HTTP 传输默认启用。Unity 窗口可以为您启动 FastMCP 服务器:
1. 打开 `Window > MCP for Unity`
2. 确保 **Transport** 下拉菜单设置为 `HTTP Local`(默认),并将 **HTTP URL** 设置为你想要的地址(默认为 `http://localhost:8080`)。
3. 点击 **Start Server**。Unity 会生成一个新的系统终端窗口,运行 `uv ... server.py --transport http`
4. 在你工作时保持该终端窗口打开;关闭它会停止服务器。如果你需要干净地关闭它,请使用 Unity 窗口中的 **Stop Session** 按钮。
> 更喜欢 stdio将传输下拉菜单更改为 `Stdio`Unity 将回退到嵌入式 TCP 桥接器,而不是启动 HTTP 服务器。
**手动启动(可选)**
您也可以从终端自己启动服务器——对 CI 或当您想查看原始日志时很有用:
```bash
uvx --from "git+https://github.com/CoplayDev/unity-mcp@v8.6.0#subdirectory=Server" mcp-for-unity --transport http --http-url http://localhost:8080
```
在客户端连接时保持进程运行。
### 🛠️ 步骤 3配置您的 MCP 客户端
将你的 MCP 客户端Claude、Cursor 等)连接到步骤 2 启动的 HTTP 服务器(自动)或使用下方的手动配置。
对于 **Claude Desktop** 用户,可以尝试下载并上传 `claude_skill_unity.zip`Unity_Skills参见这个链接https://www.claude.com/blog/skills
**选项 A配置按钮推荐用于 Claude/Cursor/VSC Copilot**
1. 在 Unity 中,前往 `Window > MCP for Unity`
2. 从下拉菜单选择你的 Client/IDE。
3. 点击 `Configure` 按钮。(或点击 `Configure All Detected Clients` 自动尝试配置所有检测到的客户端,但会更慢。)
4. 寻找绿色状态指示器 🟢 和 "Connected ✓"。*(这会写入指向你在步骤 2 中启动的服务器的 HTTP `url`)。*
<details><summary><strong>客户端特定故障排除</strong></summary>
- **VSCode**:使用 `Code/User/mcp.json` 和顶级 `servers.unityMCP`、`"type": "http"` 以及步骤 2 中的 URL。在 Windows 上,当您切换回 stdio 时MCP for Unity 仍然偏好绝对 `uv.exe` 路径。
- **Cursor / Windsurf** [(**帮助链接**)](https://github.com/CoplayDev/unity-mcp/wiki/1.-Fix-Unity-MCP-and-Cursor,-VSCode-&-Windsurf):如果缺少 `uv`MCP for Unity 窗口会显示"uv Not Found"和快速 [HELP] 链接以及"Choose `uv` Install Location"按钮。
- **Claude Code** [(**帮助链接**)](https://github.com/CoplayDev/unity-mcp/wiki/2.-Fix-Unity-MCP-and-Claude-Code):如果找不到 `claude`,窗口会显示"Claude Not Found"和 [HELP] 以及"Choose Claude Location"按钮。注销现在会立即更新 UI。
</details>
**选项 B手动配置**
如果自动设置失败或您使用不同的客户端:
1. **找到您的 MCP 客户端配置文件。**(查看客户端文档)。
* *Claude 示例macOS* `~/Library/Application Support/Claude/claude_desktop_config.json`
* *Claude 示例Windows* `%APPDATA%\Claude\claude_desktop_config.json`
2. **编辑文件** 以添加/更新 `mcpServers` 部分,使其指向步骤 2 中的 HTTP 端点。
<details>
<summary><strong>点击查看客户端特定的 JSON 配置片段...</strong></summary>
---
**Claude Code**
如果您正在使用 Claude Code您可以使用以下命令注册 MCP 服务器:
**macOS**
```bash
claude mcp add --scope user UnityMCP -- uv --directory /Users/USERNAME/Library/AppSupport/UnityMCP/UnityMcpServer/src run server.py
```
**Windows**
```bash
claude mcp add --scope user UnityMCP -- "C:/Users/USERNAME/AppData/Local/Microsoft/WinGet/Links/uv.exe" --directory "C:/Users/USERNAME/AppData/Local/UnityMCP/UnityMcpServer/src" run server.py
```
**VSCode所有操作系统 HTTP 默认)**
```json
{
"servers": {
"unityMCP": {
"type": "http",
"url": "http://localhost:8080/mcp"
}
}
}
```
**macOS / Windows / LinuxClaude Desktop、Cursor、Claude Code、Windsurf 等 HTTP 默认)**
```json
{
"mcpServers": {
"unityMCP": {
"url": "http://localhost:8080/mcp"
}
}
}
```
将 URL 设置为与您在 Unity 窗口中输入的内容匹配(包括 `/mcp`)。
#### Stdio 配置示例(传统 / 可选)
将 Unity 传输下拉菜单切换到 `Stdio`,然后使用以下 `command`/`args` 块之一。
**VSCodestdio**
```json
{
"servers": {
"unityMCP": {
"type": "stdio",
"command": "uv",
"args": [
"--directory",
"<ABSOLUTE_PATH_TO>/UnityMcpServer/src",
"run",
"server.py",
"--transport",
"stdio"
]
}
}
}
```
**macOS / Linuxstdio**
```json
{
"mcpServers": {
"unityMCP": {
"command": "uv",
"args": [
"run",
"--directory",
"/Users/YOUR_USERNAME/Library/AppSupport/UnityMCP/UnityMcpServer/src",
"server.py",
"--transport",
"stdio"
]
}
}
}
```
**Windowsstdio**
```json
{
"mcpServers": {
"unityMCP": {
"command": "C:/Users/YOUR_USERNAME/AppData/Local/Microsoft/WinGet/Links/uv.exe",
"args": [
"run",
"--directory",
"C:/Users/YOUR_USERNAME/AppData/Local/UnityMCP/UnityMcpServer/src",
"server.py",
"--transport",
"stdio"
]
}
}
}
```
根据您的平台需要替换 `YOUR_USERNAME``AppSupport` 路径段。
</details>
---
## 使用方法 ▶️
1. **打开你的 Unity 项目** 并确认 HTTP 服务器正在运行Window > MCP for Unity > Start Server。服务器启动后指示器应显示 "Session Active"。
2. **启动您的 MCP 客户端**Claude、Cursor 等)。它连接到步骤 3 中配置的 HTTP 端点——客户端不会生成额外的终端。
3. **交互!** Unity 工具现在应该在您的 MCP 客户端中可用。
示例提示:`创建一个 3D 玩家控制器``创建一个 3D 井字游戏``创建一个酷炫的着色器并应用到立方体上`。
### 💡 性能提示:使用 `batch_execute`
当你需要执行多个操作时,请使用 `batch_execute` 而不是逐个调用工具。这可以显著降低延迟和 token 成本(单次最多 25 条命令):
```text
❌ 慢:创建 5 个立方体 → 5 次 manage_gameobject 调用
✅ 快:创建 5 个立方体 → 1 次 batch_execute包含 5 条 manage_gameobject 命令)
❌ 慢:先查找对象,再逐个加组件 → N+M 次调用
✅ 快:查找 + 批量加组件 → 1 次 find + 1 次 batch_execute包含 M 条 manage_components 命令)
```
### 使用多个 Unity 实例
MCP for Unity 同时支持多个 Unity 编辑器实例。每个实例在每个 MCP 客户端会话中是隔离的。
**要将工具调用定向到特定实例:**
1. 列出可用实例:要求你的大语言模型检查 `unity_instances` 资源
2. 设置活动实例:使用 `set_active_instance`,并传入 `unity_instances` 返回的精确 `Name@hash`(例如 `MyProject@abc123`
3. 后续所有工具都会路由到该实例,直到你再次更改。如果存在多个实例且未设置活动实例,服务器会报错并提示选择实例。
**示例:**
```
用户: "列出所有 Unity 实例"
大语言模型: [显示 ProjectA@abc123 和 ProjectB@def456]
用户: "将活动实例设置为 ProjectA@abc123"
大语言模型: [调用 set_active_instance("ProjectA@abc123")]
用户: "创建一个红色立方体"
大语言模型: [在 ProjectA 中创建立方体]
```
---
## 开发和贡献 🛠️
### 开发设置和指南
查看 [README-DEV.md](docs/README-DEV.md) 获取完整的开发设置和工作流程文档。
### 添加自定义工具
MCP for Unity 使用与 Unity 的 C# 脚本绑定的 Python MCP 服务器来实现工具功能。如果您想使用自己的工具扩展功能,请参阅 **[CUSTOM_TOOLS.md](docs/CUSTOM_TOOLS.md)** 了解如何操作。
### 如何贡献
1. **Fork** 主仓库。
2. **创建问题** 讨论您的想法或错误。
3. **创建分支**`feature/your-idea` 或 `bugfix/your-fix`)。
4. **进行更改。**
5. **提交**feat: Add cool new feature
6. **推送** 您的分支。
7. **对主分支开启拉取请求**,引用您之前创建的问题。
---
## 📊 遥测和隐私
MCP for Unity 包含**注重隐私的匿名遥测**来帮助我们改进产品。我们收集使用分析和性能数据,但**绝不**收集您的代码、项目名称或个人信息。
- **🔒 匿名**:仅随机 UUID无个人数据
- **🚫 轻松退出**:设置 `DISABLE_TELEMETRY=true` 环境变量
- **📖 透明**:查看 [TELEMETRY.md](docs/TELEMETRY.md) 获取完整详情
您的隐私对我们很重要。所有遥测都是可选的,旨在尊重您的工作流程。
---
## 故障排除 ❓
<details>
<summary><strong>点击查看常见问题和修复方法...</strong></summary>
- **Unity Bridge 未运行/连接:**
- 确保 Unity 编辑器已打开。
- 检查状态窗口Window > MCP for Unity。
- 重启 Unity。
- **MCP 客户端未连接/服务器未启动:**
- 确保本地 HTTP 服务器正在运行Window > MCP for Unity > Start Server。保持生成的终端窗口打开。
- **验证服务器路径:** 双重检查您的 MCP 客户端 JSON 配置中的 --directory 路径。它必须完全匹配安装位置:
- **Windows** `%USERPROFILE%\AppData\Local\UnityMCP\UnityMcpServer\src`
- **macOS** `~/Library/AppSupport/UnityMCP/UnityMcpServer\src`
- **Linux** `~/.local/share/UnityMCP/UnityMcpServer\src`
- **验证 uv** 确保 `uv` 已安装并正常工作(`uv --version`)。
- **手动运行:** 尝试直接从终端运行服务器以查看错误:
```bash
cd /path/to/your/UnityMCP/UnityMcpServer/src
uv run server.py
```
- **配置失败:**
- 使用手动配置步骤。插件可能缺乏写入 MCP 客户端配置文件的权限。
</details>
仍然卡住?[开启问题](https://github.com/CoplayDev/unity-mcp/issues) 或 [加入 Discord](https://discord.gg/y4p8KfzrN4)
---
## 许可证 📜
MIT 许可证。查看 [LICENSE](LICENSE) 文件。
---
## Star 历史
[![Star History Chart](https://api.star-history.com/svg?repos=CoplayDev/unity-mcp&type=Date)](https://www.star-history.com/#CoplayDev/unity-mcp&Date)
## Unity AI 工具由 Coplay 提供
Coplay 提供 2 个 Unity AI 工具
- **MCP for Unity** 在 MIT 许可证下免费提供。
- **Coplay** 是一个高级 Unity AI 助手,位于 Unity 内部,功能比 MCP for Unity 更多。
(这些工具有不同的技术栈。查看这篇博客文章[比较 Coplay 和 MCP for Unity](https://www.coplay.dev/blog/comparing-coplay-and-unity-mcp)。)
<img alt="Coplay" src="docs/images/coplay-logo.png" />
## 免责声明
本项目是一个免费开源的 Unity 编辑器工具,与 Unity Technologies 无关。

View File

@ -1,6 +1,6 @@
<img width="676" height="380" alt="MCP for Unity" src="docs/images/logo.png" />
| [English](README.md) | [简体中文](README-zh.md) |
| [English](README.md) | [简体中文](docs/i18n/README-zh.md) |
|----------------------|---------------------------------|
#### Proudly sponsored and maintained by [Coplay](https://www.coplay.dev/?ref=unity-mcp) -- the best AI assistant for Unity.
@ -38,7 +38,7 @@ In Unity: `Window > Package Manager > + > Add package from git URL...`
**Need a stable/fixed version?** Use a tagged URL (requires uninstall to update):
```text
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v9.0.3
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v9.1.0
```
<details>
@ -191,7 +191,7 @@ Still stuck? [Open an Issue](https://github.com/CoplayDev/unity-mcp/issues) or [
<details>
<summary><strong>Contributing</strong></summary>
See [README-DEV.md](docs/README-DEV.md) for development setup. For custom tools, see [CUSTOM_TOOLS.md](docs/CUSTOM_TOOLS.md).
See [README-DEV.md](docs/development/README-DEV.md) for development setup. For custom tools, see [CUSTOM_TOOLS.md](docs/reference/CUSTOM_TOOLS.md).
1. Fork → Create issue → Branch (`feature/your-idea`) → Make changes → PR
</details>
@ -199,7 +199,7 @@ See [README-DEV.md](docs/README-DEV.md) for development setup. For custom tools,
<details>
<summary><strong>Telemetry & Privacy</strong></summary>
Anonymous, privacy-focused telemetry (no code, no project names, no personal data). Opt out with `DISABLE_TELEMETRY=true`. See [TELEMETRY.md](docs/TELEMETRY.md).
Anonymous, privacy-focused telemetry (no code, no project names, no personal data). Opt out with `DISABLE_TELEMETRY=true`. See [TELEMETRY.md](docs/reference/TELEMETRY.md).
</details>
---

247
docs/i18n/README-zh.md Normal file
View File

@ -0,0 +1,247 @@
<img width="676" height="380" alt="MCP for Unity" src="../images/logo.png" />
| [English](../../README.md) | [简体中文](README-zh.md) |
|----------------------|---------------------------------|
#### 由 [Coplay](https://www.coplay.dev/?ref=unity-mcp) 荣誉赞助并维护 —— Unity 最好的 AI 助手。
[![Discord](https://img.shields.io/badge/discord-join-red.svg?logo=discord&logoColor=white)](https://discord.gg/y4p8KfzrN4)
[![](https://img.shields.io/badge/Website-Visit-purple)](https://www.coplay.dev/?ref=unity-mcp)
[![](https://img.shields.io/badge/Unity-000000?style=flat&logo=unity&logoColor=blue 'Unity')](https://unity.com/releases/editor/archive)
[![Unity Asset Store](https://img.shields.io/badge/Unity%20Asset%20Store-Get%20Package-FF6A00?style=flat&logo=unity&logoColor=white)](https://assetstore.unity.com/packages/tools/generative-ai/mcp-for-unity-ai-driven-development-329908)
[![python](https://img.shields.io/badge/Python-3.10+-3776AB.svg?style=flat&logo=python&logoColor=white)](https://www.python.org)
[![](https://badge.mcpx.dev?status=on 'MCP Enabled')](https://modelcontextprotocol.io/introduction)
[![](https://img.shields.io/badge/License-MIT-red.svg 'MIT License')](https://opensource.org/licenses/MIT)
**用大语言模型创建你的 Unity 应用!** MCP for Unity 通过 [Model Context Protocol](https://modelcontextprotocol.io/introduction) 将 AI 助手Claude、Cursor、VS Code 等)与你的 Unity Editor 连接起来。为你的大语言模型提供管理资源、控制场景、编辑脚本和自动化任务的工具。
<img alt="MCP for Unity building a scene" src="../images/building_scene.gif">
---
## 快速开始
### 前置要求
* **Unity 2021.3 LTS+** — [下载 Unity](https://unity.com/download)
* **Python 3.10+****uv** — [安装 uv](https://docs.astral.sh/uv/getting-started/installation/)
* **一个 MCP 客户端** — [Claude Desktop](https://claude.ai/download) | [Cursor](https://www.cursor.com/en/downloads) | [VS Code Copilot](https://code.visualstudio.com/docs/copilot/overview) | [Windsurf](https://windsurf.com)
### 1. 安装 Unity 包
在 Unity 中:`Window > Package Manager > + > Add package from git URL...`
> [!TIP]
> ```text
> https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity
> ```
**需要一个稳定/固定版本?** 使用带 tag 的 URL更新时需要卸载才能更新
```text
https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v9.1.0
```
<details>
<summary>其他安装方式Asset Store、OpenUPM</summary>
**Unity Asset Store**
1. 访问 [Asset Store 上的 MCP for Unity](https://assetstore.unity.com/packages/tools/generative-ai/mcp-for-unity-ai-driven-development-329908)
2. 点击 `Add to My Assets`,然后通过 `Window > Package Manager` 导入
**OpenUPM**
```bash
openupm add com.coplaydev.unity-mcp
```
</details>
### 2. 启动服务器并连接
1. 在 Unity 中:`Window > MCP for Unity`
2. 点击 **Start Server**(会在 `localhost:8080` 启动 HTTP 服务器)
3. 从下拉菜单选择你的 MCP Client然后点击 **Configure**
4. 查找 🟢 "Connected ✓"
5. **连接你的客户端:** 一些客户端Cursor、Windsurf、Antigravity需要在设置里启用 MCP 开关另一些Claude Desktop、Claude Code在配置后会自动连接。
**就这些!** 试试这样的提示词:*"Create a red, blue and yellow cube"* 或 *"Build a simple player controller"*
---
<details>
<summary><strong>功能与工具</strong></summary>
### 关键功能
* **自然语言控制** — 指示你的大语言模型执行 Unity 任务
* **强大工具** — 管理资源、场景、材质、脚本和编辑器功能
* **自动化** — 自动化重复的 Unity 工作流程
* **可扩展** — 可与多种 MCP Client 配合使用
### 可用工具
`manage_asset``manage_editor``manage_gameobject``manage_components``manage_material``manage_prefabs``manage_scene``manage_script``manage_scriptable_object``manage_shader``manage_vfx``batch_execute``find_gameobjects``find_in_file``read_console``refresh_unity``run_tests``get_test_job``execute_menu_item``apply_text_edits``script_apply_edits``validate_script``create_script``delete_script``get_sha`
### 可用资源
`custom_tools``unity_instances``menu_items``get_tests``gameobject``gameobject_components``editor_state``editor_selection``editor_prefab_stage``project_info``project_tags``project_layers`
**性能提示:** 多个操作请使用 `batch_execute` — 比逐个调用快 10-100 倍!
</details>
<details>
<summary><strong>手动配置</strong></summary>
如果自动设置不生效,请把下面内容添加到你的 MCP Client 配置文件中:
**HTTP默认 — 适用于 Claude Desktop、Cursor、Windsurf**
```json
{
"mcpServers": {
"unityMCP": {
"url": "http://localhost:8080/mcp"
}
}
}
```
**VS Code**
```json
{
"servers": {
"unityMCP": {
"type": "http",
"url": "http://localhost:8080/mcp"
}
}
}
```
<details>
<summary>Stdio 配置(旧版)</summary>
**macOS/Linux**
```json
{
"mcpServers": {
"unityMCP": {
"command": "uv",
"args": ["run", "--directory", "/Users/YOUR_USERNAME/Library/AppSupport/UnityMCP/UnityMcpServer/src", "server.py", "--transport", "stdio"]
}
}
}
```
**Windows**
```json
{
"mcpServers": {
"unityMCP": {
"command": "C:/Users/YOUR_USERNAME/AppData/Local/Microsoft/WinGet/Links/uv.exe",
"args": ["run", "--directory", "C:/Users/YOUR_USERNAME/AppData/Local/UnityMCP/UnityMcpServer/src", "server.py", "--transport", "stdio"]
}
}
}
```
</details>
</details>
<details>
<summary><strong>多个 Unity 实例</strong></summary>
MCP for Unity 支持多个 Unity Editor 实例。要将操作定向到某个特定实例:
1. 让你的大语言模型检查 `unity_instances` 资源
2. 使用 `set_active_instance` 并传入 `Name@hash`(例如 `MyProject@abc123`
3. 后续所有工具都会路由到该实例
</details>
<details>
<summary><strong>Roslyn 脚本验证(高级)</strong></summary>
要使用能捕获未定义命名空间、类型和方法的 **Strict** 验证:
1. 安装 [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity)
2. `Window > NuGet Package Manager` → 安装 `Microsoft.CodeAnalysis` v4.14.0
3. 同时安装 `SQLitePCLRaw.core``SQLitePCLRaw.bundle_e_sqlite3`
4. 在 `Player Settings > Scripting Define Symbols` 中添加 `USE_ROSLYN`
5. 重启 Unity
<details>
<summary>手动 DLL 安装(如果 NuGetForUnity 不可用)</summary>
1. 从 [NuGet](https://www.nuget.org/packages/Microsoft.CodeAnalysis.CSharp/) 下载 `Microsoft.CodeAnalysis.CSharp.dll` 及其依赖项
2. 将 DLL 放到 `Assets/Plugins/` 目录
3. 确保 .NET 兼容性设置正确
4. 在 Scripting Define Symbols 中添加 `USE_ROSLYN`
5. 重启 Unity
</details>
</details>
<details>
<summary><strong>故障排除</strong></summary>
* **Unity Bridge 无法连接:** 检查 `Window > MCP for Unity` 状态,重启 Unity
* **Server 无法启动:** 确认 `uv --version` 可用,并检查终端错误
* **Client 无法连接:** 确认 HTTP server 正在运行,并且 URL 与你的配置一致
**详细的设置指南:**
* [Fix Unity MCP and Cursor, VSCode & Windsurf](https://github.com/CoplayDev/unity-mcp/wiki/1.-Fix-Unity-MCP-and-Cursor,-VSCode-&-Windsurf) — uv/Python 安装、PATH 问题
* [Fix Unity MCP and Claude Code](https://github.com/CoplayDev/unity-mcp/wiki/2.-Fix-Unity-MCP-and-Claude-Code) — Claude CLI 安装
* [Common Setup Problems](https://github.com/CoplayDev/unity-mcp/wiki/3.-Common-Setup-Problems) — macOS dyld 错误、FAQ
还是卡住?[开一个 Issue](https://github.com/CoplayDev/unity-mcp/issues) 或 [加入 Discord](https://discord.gg/y4p8KfzrN4)
</details>
<details>
<summary><strong>贡献</strong></summary>
开发环境设置见 [README-DEV.md](../development/README-DEV.md)。自定义工具见 [CUSTOM_TOOLS.md](../reference/CUSTOM_TOOLS.md)。
1. Fork → 创建 issue → 新建分支(`feature/your-idea`)→ 修改 → 提 PR
</details>
<details>
<summary><strong>遥测与隐私</strong></summary>
匿名、注重隐私的遥测(不包含代码、项目名或个人数据)。可通过 `DISABLE_TELEMETRY=true` 关闭。详见 [TELEMETRY.md](../reference/TELEMETRY.md)。
</details>
---
**许可证:** MIT — 查看 [LICENSE](../../LICENSE) | **需要帮助?** [Discord](https://discord.gg/y4p8KfzrN4) | [Issues](https://github.com/CoplayDev/unity-mcp/issues)
---
## Star 历史
[![Star History Chart](https://api.star-history.com/svg?repos=CoplayDev/unity-mcp&type=Date)](https://www.star-history.com/#CoplayDev/unity-mcp&Date)
<details>
<summary><strong>研究引用</strong></summary>
如果你正在进行与 Unity-MCP 相关的研究,请引用我们!
```bibtex
@inproceedings{10.1145/3757376.3771417,
author = {Wu, Shutong and Barnett, Justin P.},
title = {MCP-Unity: Protocol-Driven Framework for Interactive 3D Authoring},
year = {2025},
isbn = {9798400721366},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3757376.3771417},
doi = {10.1145/3757376.3771417},
series = {SA Technical Communications '25}
}
```
</details>
## Coplay 的 Unity AI 工具
Coplay 提供 3 个 Unity AI 工具:
- **MCP for Unity** 在 MIT 许可证下免费提供。
- **Coplay** 是一个运行在 Unity 内的高级 Unity AI 助手,功能超过 MCP for Unity。
- **Coplay MCP** 是 Coplay 工具的“目前免费”版 MCP。
(这些工具有不同的技术栈。参见这篇博客文章:[comparing Coplay to MCP for Unity](https://coplay.dev/blog/coplay-vs-coplay-mcp-vs-unity-mcp)。)
<img alt="Coplay" src="../images/coplay-logo.png" />
## 免责声明
本项目是一个免费开源的 Unity Editor 工具,与 Unity Technologies 无关。