> 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/unity-plugin/setting-up-unity-plugin.md). Agents can also search and read this documentation through its [MCP server](https://docs.convai.com/api-docs/~gitbook/mcp).

# 设置 Unity 插件

按照这些说明将 Unity 插件设置到你的项目中。

{% hint style="info" %}
该文件结构属于从文档中下载的插件核心版本。
{% endhint %}

### 设置 Unity 插件

在菜单栏中，依次选择 Convai > API Key Setup。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FmzTr6EgpLD64x6u6AhXs%2Fimage.png?alt=media&amp;token=9247b33a-a696-47a7-92a0-814cd19566ed" alt=""><figcaption></figcaption></figure>

前往 [convai.com](https://convai.com)，然后登录你的 Convai 账户。登录后会跳转到控制面板。在控制面板中获取你的 API 密钥。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FGbUuZB1wZAeWr8cqGf1N%2Fimage.png?alt=media&amp;token=8197ae1f-0bc3-4cc6-94d2-df5fb1e02fad" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FUaDkwcZnZhl6vbv2c1EE%2Fimage.png?alt=media&amp;token=b6155743-5aeb-4eda-b052-429a3f8abf94" alt=""><figcaption></figcaption></figure>

输入 API 密钥，然后点击 begin。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FgoH9XrQ2eiAKOzbKzs4f%2Fimage.png?alt=media&amp;token=e5de12ef-bc4b-472c-af37-d595f97e4daa" alt=""><figcaption></figcaption></figure>

这会在 resources 文件夹中创建一个 APIKey 资源，其中包含你的 API 密钥。

依次选择 Convai > Demo > Scenes > Full Features，打开演示场景。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FXVkMwywXPEvxZlK8PVAo%2Fimage.png?alt=media&amp;token=b4997d10-d2eb-4291-b792-0275967f7c20" alt=""><figcaption></figcaption></figure>

点击 Convai NPC Amelia 并添加角色 ID（也可以保留默认角色 ID）。你可以在此页面获取自定义角色的角色 ID [Broken mention](broken://pages/35a85ab8078743525dfb21372f6c08398990e426)。现在，你可以与该角色交谈。脚本已设置为：你必须走近角色，他们才能听到你的声音。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FG36vjQFS4B9CXjvvrfZH%2Fimage.png?alt=media&amp;token=bed1bef3-e08b-434a-a4e3-1d53e95266d3" alt=""><figcaption></figcaption></figure>

现在，你可以试用 Convai 演示场景，与其中的角色交谈。她叫 Amelia，喜欢徒步旅行！

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FGqMgJL3VIQDd8GkZB4wi%2Fimage.png?alt=media&amp;token=ce593e9f-44d6-4cd6-af05-4dadc1415f38" alt=""><figcaption></figcaption></figure>

你可以打开 Convai NPC 脚本，复制或扩展该脚本来创建新的 NPC。

{% hint style="warning" %}
建议扩展 ConvaiNPC.cs 脚本，而不是直接修改它，以保持与其他脚本的兼容性。
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/setting-up-unity-plugin.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
