> 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/features/vision/quick-start.md).

# 视觉快速开始

只需三步即可为现有的 Convai 场景添加 Vision。SDK 会在你将 `ConvaiRoomManager` 设置为视频模式。

### 前提条件

开始前，请确认：

* [ ] 一个 `ConvaiCharacter` 已在场景中，并会在播放模式下响应语音

{% stepper %}
{% step %}

#### 将 Connection Type 设置为 Video

选择 `ConvaiRoomManager` 层级视图中的 GameObject。在 Inspector 中，将 **连接类型** 到 **视频**.

<figure><img src="/files/6a3b89748bee39b21eca9722ad6109086352212f" alt="Connection Type set to Video on ConvaiRoomManager in the Inspector"><figcaption><p>ConvaiRoomManager 上的 Connection Type 设置为 Video。</p></figcaption></figure>

会立即出现一个对话框：

> **Convai Vision 设置** — Connection Type 已设为 Video，但缺少必需的视觉组件。添加 `ConvaiVisionPublisher` 和 `CameraVisionFrameSource` 到这个 ConvaiRoomManager 下？

点击 **添加组件**.

<figure><img src="/files/ca344105500614f945561b927d3d0c9e2a5d5ad6" alt="Convai Vision Setup dialog prompt"><figcaption><p>Convai Vision 设置对话框提示。</p></figcaption></figure>

SDK 会创建一个名为以下名称的子 GameObject： **ConvaiVisionRoot** 下的 `ConvaiRoomManager` 并添加以下两个组件： `ConvaiVisionPublisher` 和 `CameraVisionFrameSource` 到其中。
{% endstep %}

{% step %}

#### 指定一个摄像头

选择 **ConvaiVisionRoot** GameObject（作为……的子对象 `ConvaiRoomManager`）。在 `CameraVisionFrameSource` 组件中，找到 **目标摄像机** 字段。

* 如果你的场景中有一个 `摄像机` 带有 **MainCamera**，请将该字段留空——该组件会在运行时自动解析。
* 要捕获特定摄像头（俯视视角、监控摄像头等），请将该摄像头拖到 **目标摄像机** 字段。

默认的 **捕获预设** 为 **均衡** （1280 × 720，15 fps），适用于大多数场景。

如果 **目标摄像机** 为空，并且场景中没有任何摄像头带有 **MainCamera**，则帧源会进入 `失败` 状态。请始终显式指定一个摄像头，或确保有一个摄像头具有 **MainCamera** 标签。

<figure><img src="/files/ac34c7bb48871e5d56d4ef15a7e83503af861922" alt="Target Camera assigned on CameraVisionFrameSource in the Inspector"><figcaption><p>在 CameraVisionFrameSource 上指定的 Target Camera。</p></figcaption></figure>
{% endstep %}

{% step %}

#### 使用调试预览进行验证

在任意场景 GameObject 上，点击 **添加组件** → **Convai/Vision/Vision Debug Preview（仅限编辑器）**.

按下 **Play**。游戏视图中会出现一个覆盖层，显示实时摄像头画面和统计面板。房间连接后，FPS 计数器会递增，帧计数也会增加。

<figure><img src="/files/90229f8dc121bfae0cd5e1d796e04aecabb1da9c" alt="Vision Debug Preview component added to a scene GameObject"><figcaption><p>已添加 Vision Debug Preview 组件。</p></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**成功：** Debug Preview 覆盖层显示实时图像，且 FPS 计数器不为零。读取 `ConvaiVisionPublisher.IsPublishing` 在任意脚本中返回 `true`。角色现在会在音频对话之外，同时接收场景摄像头画面。
{% endhint %}

{% hint style="warning" %}
如果覆盖层仍为空白或 FPS 计数器显示为零，请检查 `ConvaiRoomManager.Connection Type` 被设置为 **视频** 以及房间是否已完全连接。请参阅 [排查 Vision 问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/troubleshooting-and-diagnostics.md) 以进行逐步诊断。
{% endhint %}

### 手动设置组件

如果你点击了 **稍后** 对话框中的该选项，或者想将组件放置到特定 GameObject 上，请手动添加：

1. 选择目标 GameObject（任何持久化场景对象——通常位于你的 NPC 上或附近）。
2. **添加组件** → 搜索 **Convai Vision Publisher**.
3. 在同一个 GameObject（或其子对象）上， **添加组件** → **Convai/视觉/摄像机视觉帧源**.
4. 分配 **目标摄像机** 如果不使用 `Camera.main`.
5. 请将 **Source** 字段在 `ConvaiVisionPublisher` 留空——发布器会自动发现 `CameraVisionFrameSource` 运行时同一 GameObject 上的它。只有在场景中有多个帧源时，才需要显式指定它。

<figure><img src="/files/e969d94e4fd680a706f68678cd75462e5fd01cd2" alt="Manual vision setup showing ConvaiVisionPublisher and CameraVisionFrameSource components"><figcaption><p>手动视觉设置——发布器和帧源组件。</p></figcaption></figure>

### 下一步

{% content-ref url="/pages/6ebd5ccda4df347e0fb3db3967023f01c8054427" %}
[视觉的工作方式](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/how-vision-works.md)
{% endcontent-ref %}

{% content-ref url="/pages/3c41ddceb11fc2af6b830a08a48c437b590c8882" %}
[视觉帧来源](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/frame-sources.md)
{% endcontent-ref %}

{% content-ref url="/pages/b15c237537e3521d8e360ca90de5e9b15be340ec" %}
[发布策略](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/publishing-and-policies.md)
{% endcontent-ref %}

{% content-ref url="/pages/86612bc613c5a299a468b71b3fb8a40e625ee1fe" %}
[排查 Vision 问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/troubleshooting-and-diagnostics.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:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/quick-start.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
