> 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

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

两种方法都会安装 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.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" %}
**依赖冲突：** 如果你的项目已将 `com.unity.inputsystem` 或 `com.unity.ugui` 固定为较旧版本于 `Packages/manifest.json`，则安装将失败或产生版本不匹配。打开 `Packages/manifest.json`，删除或更新冲突的版本条目，然后重试。
{% endhint %}

{% hint style="success" %}
**安装完成** 当 Package Manager 列表中出现带有绿色对勾且版本为 <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.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="info" %}
要将 SDK 更新到较新版本，请返回到 **我的资源** 在包管理器中，选择该 SDK，并单击 **Update**.
{% endhint %}

{% hint style="success" %}
**安装完成** 当 Package Manager 列表中出现版本为 <code class="expression">space.vars.unity\_sdk\_version</code>。你还会看到一个新的 **Convai** Unity 菜单栏中的菜单项。
{% endhint %}
{% 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 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/getting-started/installation.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.
