> 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/getting-started/installation.md).

# 安装 Convai Unity SDK

使用 Package Manager 或 Asset Store 将 Convai Unity SDK 安装到 Unity 项目中，以便 SDK 及其依赖项正确解析。

Convai Unity SDK 可通过两种渠道获取。使用 **包管理器** 适用于新项目，或当你不想管理资源商店下载时——该包可直接从 Convai 注册表解析，无需手动下载。使用 **资源商店** 如果你的项目已经从资源商店资料库获取包，或者你的工作室通过“My Assets”管理包版本。

这两种方法都需要 Unity <code class="expression">space.vars.unity\_min\_version</code> 并安装 SDK 版本 <code class="expression">space.vars.unity\_sdk\_version</code> 以及相同的四个必需依赖项。

{% tabs %}
{% tab title="包管理器" %}
{% stepper %}
{% step %}

#### 打开包管理器

在 Unity 编辑器菜单栏中，选择 **窗口 > 包管理器**.

包管理器窗口会打开。继续之前，请确认你已连接到互联网。
{% endstep %}

{% step %}

#### 按名称添加包

点击 **+** 按钮，位于包管理器窗口左上角。选择 **按名称添加包** 从下拉菜单中。

会出现一个文本字段，提示输入包名称。
{% endstep %}

{% step %}

#### 输入包名称

在名称字段中输入或粘贴以下标识符，然后单击 **添加**:

```
com.convai.convai-sdk-for-unity
```

Unity 会联系注册表、解析该包并开始下载。四个依赖项会自动安装：

| 包                                 | 版本                                                                        |
| --------------------------------- | ------------------------------------------------------------------------- |
| `com.unity.ai.inference`          | <code class="expression">space.vars.dep\_ai\_inference\_version</code>    |
| `com.unity.nuget.newtonsoft-json` | <code class="expression">space.vars.dep\_newtonsoft\_json\_version</code> |
| `com.unity.ugui`                  | <code class="expression">space.vars.dep\_ugui\_version</code>             |
| `com.unity.inputsystem`           | <code class="expression">space.vars.dep\_inputsystem\_version</code>      |

请等待 Unity 编辑器右下角的进度条完成后再继续。
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
**依赖冲突：** 如果你的项目已将这四个包中的任何一个在 `Packages/manifest.json`中固定为较旧版本，安装将失败或导致版本不匹配。打开 `Packages/manifest.json`，移除或更新冲突的版本条目，然后重试。
{% endhint %}

{% hint style="success" %}
**安装完成** 当 Convai SDK for Unity 条目在包管理器列表中显示绿色对勾和版本 <code class="expression">space.vars.unity\_sdk\_version</code>时。你还会在 **Convai** Unity 菜单栏中看到一个新的
{% endhint %}
{% endtab %}

{% tab title="资源商店" %}
{% stepper %}
{% step %}

#### 将 SDK 添加到你的资源商店账户

打开 [Unity 资源商店](https://assetstore.unity.com/) 在浏览器中。搜索 **Convai SDK for Unity** 并打开该列表。单击 **添加到我的资源**，如有提示，请使用你的 Unity ID 登录。

按钮会变为 **在 Unity 中打开** ，表示该资源已添加到你的账户。
{% endstep %}

{% step %}

#### 打开包管理器

在 Unity 编辑器菜单栏中，选择 **窗口 > 包管理器**.
{% endstep %}

{% step %}

#### 切换到“我的资源”

在包管理器窗口中，点击左上角的包来源下拉菜单（显示 **Packages: In Project** 或类似内容），然后选择 **我的资源**.

你的资源商店资料库将加载。找到 **Convai SDK for Unity** 在列表中。
{% endstep %}

{% step %}

#### 下载并导入

选择 **Convai SDK for Unity** 在列表中。单击 **下载**，然后点击 **导入** ，待下载完成后。

Unity 会导入该包并自动安装四个依赖项：

| 包                                 | 版本                                                                        |
| --------------------------------- | ------------------------------------------------------------------------- |
| `com.unity.ai.inference`          | <code class="expression">space.vars.dep\_ai\_inference\_version</code>    |
| `com.unity.nuget.newtonsoft-json` | <code class="expression">space.vars.dep\_newtonsoft\_json\_version</code> |
| `com.unity.ugui`                  | <code class="expression">space.vars.dep\_ugui\_version</code>             |
| `com.unity.inputsystem`           | <code class="expression">space.vars.dep\_inputsystem\_version</code>      |

请等待 Unity 编辑器右下角的进度条完成后再继续。
{% endstep %}
{% endstepper %}

若要稍后将 SDK 更新到更高版本，请返回到 **我的资源** 在包管理器中，选择该 SDK，然后单击 **Update**.

当 Convai SDK for Unity 条目在包管理器列表中显示版本时，安装即完成 <code class="expression">space.vars.unity\_sdk\_version</code>时。你还会在 **Convai** Unity 菜单栏中看到一个新的
{% endtab %}
{% endtabs %}

### 下一步

安装 SDK 后，通过输入你的 API 密钥将项目连接到 Convai。

{% content-ref url="/pages/3a95f57092cf5e9062d0377485e90f72b444fbd3" %}
[配置 API 密钥](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/getting-started/configure-api-key.md)
{% endcontent-ref %}


---

# 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/convai-unity-sdk/getting-started/installation.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.
