> 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 可通过两种渠道获取。使用 **Package Manager** 适用于新项目，或您不想手动管理 Asset Store 下载的情况——该软件包会直接从 Convai 注册表解析，无需手动下载。若您的项目已从 Asset Store 库获取软件包，或您的工作室通过 My Assets 管理软件包版本，则使用 **Asset Store** 。

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

{% tabs %}
{% tab title="Package Manager" %}
{% stepper %}
{% step %}

#### 打开 Package Manager

在 Unity 编辑器菜单栏中，选择 **Window > Package Manager**.

Package Manager 窗口随即打开。继续之前，请确认已连接到互联网。
{% endstep %}

{% step %}

#### 按名称添加软件包

点击 Package Manager 窗口左上角的 **+** 按钮。从下拉菜单中选择 **按名称添加软件包** 。

系统会显示一个文本字段，提示输入软件包名称。
{% endstep %}

{% step %}

#### 输入软件包名称

在 Name 字段中键入或粘贴以下标识符，然后点击 **添加**:

```
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" %}
**安装完成** 当 Package Manager 列表中出现 Convai SDK for Unity 条目，且旁边显示绿色勾号和版本号 <code class="expression">space.vars.unity\_sdk\_version</code>时，即表示安装完成。您还会在 Unity 菜单栏中看到新增的 **Convai** 菜单项。
{% endhint %}
{% endtab %}

{% tab title="Asset Store" %}
{% stepper %}
{% step %}

#### 将 SDK 添加到您的 Asset Store 帐户

在浏览器中打开 [Unity Asset Store](https://assetstore.unity.com/) 。搜索 **Convai SDK for Unity** 并打开商品页面。点击 **添加到 My Assets**；如果系统提示，请使用 Unity ID 登录。

资产添加到帐户后，该按钮会变为 **在 Unity 中打开** 。
{% endstep %}

{% step %}

#### 打开 Package Manager

在 Unity 编辑器菜单栏中，选择 **Window > Package Manager**.
{% endstep %}

{% step %}

#### 切换到 My Assets

在 Package Manager 窗口中，点击左上角的软件包来源下拉菜单（当前显示 **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 更新到较新版本，请返回 **我的资源** 在 Package Manager 中选择该 SDK，然后点击 **更新**.

当 Package Manager 列表中的 Convai SDK for Unity 条目显示版本号 <code class="expression">space.vars.unity\_sdk\_version</code>时，即表示安装完成。Unity 菜单栏中还会出现一个新的 **Convai** 菜单项。
{% endtab %}
{% endtabs %}

### 后续步骤

安装 SDK 后，输入 API 密钥即可将项目连接到 Convai。

{% content-ref url="/pages/3a95f57092cf5e9062d0377485e90f72b444fbd3" %}
[配置 API 密钥](https://docs.convai.com/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.
