> 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/import-and-run-sample-scenes.md).

# 导入并运行示例场景

导入捆绑的示例场景，并在构建自己的场景之前验证 SDK 是否已正确安装并连接。

Convai Unity SDK 附带三个示例场景。运行其中一个，是在构建自己的场景之前，最快确认安装、API 密钥和音频设置是否正常的方法。

| 示例         | 说明                                                             |
| ---------- | -------------------------------------------------------------- |
| **基础示例**   | 使用以下角色演示核心设置和交互流程： `Convai_Char_Robot`，一个非人形角色                 |
| **口型同步示例** | 高品质角色 `Sofia` ，带有实时口型同步；此外还提供一个调试中心，可在 Play 模式下查看情绪、动态上下文和视觉状态 |
| **多角色示例**  | 一个共享房间示例，展示多个 Convai 角色、交互目标选择、对话记录 UI，以及运行时名册变更               |

根据 SDK 的安装方式，查找示例的步骤有所不同。

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

#### 打开 Package Manager

在 Unity 编辑器中，打开 **Window > Package Manager**。在左上角的下拉菜单中，选择 **In Project**，然后从列表中选择 **Convai SDK for Unity** 。
{% endstep %}

{% step %}

#### 导入示例

在右侧的详情面板中，点击 **Samples** 选项卡。点击所需示例旁的 **Import** 。

Unity 会将示例资源复制到 `Assets/Samples/Convai SDK for Unity/<version>/`。Project 窗口中会出现一个新文件夹，位于 `Assets/Samples/` 下。
{% endstep %}

{% step %}

#### 打开场景

在 Project 窗口中，找到导入的示例文件夹，然后打开其中的 `.unity` 场景文件。
{% endstep %}
{% endstepper %}
{% endtab %}

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

#### 查找示例

通过 Asset Store 安装时，所有示例场景都会自动导入项目。在 Project 窗口中，导航至：

```
Assets/Convai SDK For Unity/Samples/
```

其中包含三个文件夹： `BasicSample`, `LipSyncSample`和 `MultiCharacterSample`.
{% endstep %}

{% step %}

#### 打开场景

打开要运行的示例文件夹中的 `.unity` 场景文件。
{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

场景打开后：

{% stepper %}
{% step %}

#### 进入 Play 模式

按下 **播放**。SDK 初始化时，Unity 控制台会记录以下内容：

* `[ConvaiRuntime] Started successfully` — SDK 已初始化所有内部服务
* `[RoomConnectionRuntimeAdapter] Room connection succeeded (mode=create).` — 房间已连接到 Convai

对着麦克风说话。角色会以语音和文本形式作出回应。

如果没有出现回应，并且控制台显示警告，请查看 [验证设置](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/getting-started/validate-your-setup.md) ，获取诊断检查清单。
{% endstep %}
{% endstepper %}

在 LipSync Sample 中， **Sample Debug Hub** 面板已位于场景中。在游戏视图中点击 Emotion、Context 或 Vision 按钮，即可打开抽屉面板；角色说话时，面板会显示实时状态。

### 示例渲染管线说明

示例场景使用通用渲染管线 (URP) 构建。如果项目使用其他渲染管线，导入后材质可能会显示为粉色。请使用 **编辑 > 渲染 > 材质**，然后选择适用于该管线的转换选项。

### 后续步骤

确认 SDK 正常运行后，请先了解各个场景组件的作用，再搭建自己的设置。

{% content-ref url="/pages/e9f6a66a2fa7574cb77509cf3bffb7e711540c85" %}
[场景组件参考](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/getting-started/scene-components.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/import-and-run-sample-scenes.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.
