> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/ai-coding-assistant.md).

# AI 编码助手

Convai AI 编码助手集成会向 Unity 的官方 MCP 服务器添加 Convai 专用工具，因此代码代理可以检查、配置并诊断你项目中的 Convai 组件，而不是由你手动连接它们。如果你已经在使用受支持的代码代理，并希望该代理理解 Convai 房间、角色、动作、口型同步、具身模块（如注视和情绪）、转录文本以及视觉功能，就可以使用它。连接后，你只需用自然语言提示代理，并在 Unity 编辑器中查看生成的更改。

{% hint style="info" %}
**开始之前：** 该集成需要 <code class="expression">space.vars.unity\_recommended\_version</code> 或更高版本，以及兼容的 `com.unity.ai.assistant` 包。请参见 [AI 编码助手快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/ai-coding-assistant/quick-start.md) 以获取完整的前置条件检查和设置演练。
{% endhint %}

### 该集成新增的内容

Unity 的官方 MCP 服务器，由 `com.unity.ai.assistant` 包提供，为代码代理提供用于 GameObject、脚本、资源和场景操作的通用工具，但并不了解 Convai 组件。Convai Unity SDK 添加了 37 个了解 SDK 的工具，并带有一个 `Convai.*` 名称前缀——例如 `Convai.ConfigureCharacter`, `Convai.ConfigureLipSync`, `Convai.ConfigureGaze`，以及 `Convai.DiagnoseConversation` ——它们只读取和修改 Convai 组件，例如 `ConvaiManager`、角色、动作、口型同步、具身模块（注视、身体动画、肢体语言、情绪）、转录文本和叙事部分。Unity MCP 工具仍然负责通用的 GameObject、脚本和场景操作。Convai 工具绝不会接收或返回 API 密钥，而修改类 Convai 工具会使用 Unity 的撤销系统，而不是自动保存场景。

### 受支持的代码代理

该集成支持五种代码代理：Codex、Claude Code、Cursor、Gemini 和 VS Code Copilot。为某个代理安装支持时，会将一个受管理的 Convai 指令块写入该代理自己的指令文件中—— `AGENTS.md` 用于 Codex， `CLAUDE.md` 用于 Claude Code， `.cursor/rules/convai-unity-sdk.mdc` 用于 Cursor， `GEMINI.md` 用于 Gemini，以及 `.github/copilot-instructions.md` 用于 VS Code Copilot——将代理指向打包的 `convai-unity-sdk` 技能。请参见 [受支持的代码代理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/ai-coding-assistant/supported-coding-agents.md) 以获取每个代理的确切文件路径和安装行为。

### 将代码代理连接到你的项目

打开 **Convai > Convai 编辑器** 在 Unity 编辑器菜单中，然后选择 **AI 编码** 在窗口的导航栏中开始。该部分的 **设置健康状态** 卡片会检查 <code class="expression">space.vars.unity\_recommended\_version</code> 或更高版本、兼容的 `com.unity.ai.assistant` 包、打包的 Convai 技能，以及 37 工具契约，并为任何失败的检查提供内联 **修复方法** 按钮。打开 **项目设置 > AI > Unity MCP 服务器** ——直接，或通过 **打开 Unity MCP 服务器设置** 按钮——接受 Unity 针对 MCP Server 功能的条款，并确认哪些 MCP 客户端已连接到你的项目。然后点击 **安装** 在受支持的代码代理旁边，位于 **受管理的项目说明** 卡片中写入其受管理的指令块。请参见 [AI 编码助手快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/ai-coding-assistant/quick-start.md) 以获取完整演练。

### 你可以要求已连接代理执行的操作

连接代码代理后，你可以用自然语言提示它，而不是手动连接组件。典型请求包括：

* 构建一个包含玩家和角色的对话场景
* 添加聊天 UI 以显示对话转录内容
* 在按住说话与免持对话输入之间切换
* 向场景中添加供角色参考的对象
* 启用视觉功能，以便角色可以看到场景
* 为角色配置注视、身体动画、肢体语言或情绪

代理会对 Convai 组件使用 Convai 工具，对通用 GameObject、脚本和场景操作使用 Unity 自己的 MCP 工具，然后报告它更改了哪些实例 ID。请参见 [MCP 工具参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/ai-coding-assistant/mcp-tools-reference.md) 以获取代理可用的全部 Convai 工具列表。

### AI 编码助手页面

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>AI 编码助手快速入门</strong><br>将代码代理连接到你的 Unity 项目，并端到端验证设置。</td><td><a href="/pages/fef78cf340cc23d3c5966ea9c7099beadba8f247">/pages/fef78cf340cc23d3c5966ea9c7099beadba8f247</a></td></tr><tr><td><strong>受支持的代码代理</strong><br>查找五个受支持代理各自的确切指令文件路径和安装行为。</td><td><a href="/pages/ec47f18f1ec454c3afecbec3a73f8ab46981f55c">/pages/ec47f18f1ec454c3afecbec3a73f8ab46981f55c</a></td></tr><tr><td><strong>MCP 工具参考</strong><br>参考暴露给代码代理的每个 Convai 工具，包括其用途和默认启用状态。</td><td><a href="/pages/2556d68ab00a9475a0e5c6ca8c0541b3d69dc561">/pages/2556d68ab00a9475a0e5c6ca8c0541b3d69dc561</a></td></tr><tr><td><strong>排查 AI 编码助手设置问题</strong><br>修复设置、工具注册和代理连接失败问题。</td><td><a href="/pages/19bff3d08fa0ba480410597a8a790b68a4f73b14">/pages/19bff3d08fa0ba480410597a8a790b68a4f73b14</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/ai-coding-assistant.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
