> 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。 当你将 `ConvaiRoomManager` 设置为视频模式。

### 前提条件

开始之前，请确认：

* [ ] A `ConvaiCharacter` 位于场景中，并在播放模式下对语音作出响应

{% stepper %}
{% step %}

#### 将连接类型设置为视频

选择 `ConvaiRoomManager` 层级视图中的 GameObject。在 Inspector 中，设置 **Connection Type** 设置为 **Video**.

<figure><img src="/files/6a3b89748bee39b21eca9722ad6109086352212f" alt="Connection Type set to Video on ConvaiRoomManager in the Inspector"><figcaption><p>已在 ConvaiRoomManager 上将连接类型设置为视频。</p></figcaption></figure>

会立即出现一个对话框：

> **Convai Vision 设置** ——动态视觉上下文需要视频发布器和帧源。添加 `ConvaiVisionPublisher` 和 `CameraVisionFrameSource` 到这个 ConvaiRoomManager 下？

点击 **添加组件**.

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

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

{% step %}

#### 分配一个摄像机

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

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

默认的 **Capture Preset** 是 **均衡** （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 %}

#### 使用 Debug Preview 进行验证

在任意场景 GameObject 上，点击 **Add Component** → **Convai/Vision/视觉调试预览（仅编辑器）**.

按 **播放**。Game 视图中会出现一个叠加层，显示实时摄像机画面和统计面板。房间连接成功后，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` 已设置为 **Video** 并且房间已完全连接。请参阅 [排查 Vision 问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/troubleshooting-and-diagnostics.md) 以进行逐步诊断。
{% endhint %}

### 手动设置组件

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

1. 选择目标 GameObject（任何持久存在的场景对象——通常位于你的 NPC 上或附近）。
2. **Add Component** → 搜索 **Convai Vision Publisher**.
3. 在同一个 GameObject（或子对象）上， **Add Component** → **Convai/Vision/Camera Vision Frame Source**.
4. 分配 **目标摄像机** 如果未使用 `Camera.main`.
5. 请将 **来源** 字段标识于 `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" %}
[排查视觉问题](/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, and the optional `goal` 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>&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.
