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

# 快速开始

## 你的第一个 Vision 设置

本指南将带你完成让 Convai 角色从你的 Unity 场景接收实时摄像头画面的最少步骤。SDK 可以自动为你添加所需组件——请按照下面的主要流程操作；如果你关闭了提示，或者需要自定义放置位置，则使用手动流程。

{% hint style="info" %}
**先决条件**

* 一个带有 `ConvaiCharacter` 组件且已设置并正常工作的 Unity 场景（角色应能对语音做出响应）。
* 你的 Convai API 密钥配置在 **工具 → Convai → 配置**.
  {% endhint %}

{% stepper %}
{% step %}
**将 Connection Type 设置为 Video**

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

<figure><img src="/files/6a3b89748bee39b21eca9722ad6109086352212f" alt=""><figcaption></figcaption></figure>

会立即出现一个对话框：

> **Convai Vision 设置** Connection Type 已设置为 Video，但缺少所需的视觉组件。添加 `ConvaiVisionPublisher` 是位于 `CameraVisionFrameSource` 到此 ConvaiRoomManager 下吗？

单击 **添加组件**.

<figure><img src="/files/ca344105500614f945561b927d3d0c9e2a5d5ad6" alt=""><figcaption></figcaption></figure>

SDK 会创建一个名为 **ConvaiVisionRoot** 位于 `ConvaiRoomManager` 并添加这两个 `ConvaiVisionPublisher` 是位于 `CameraVisionFrameSource` 到其中。无需再进行其他组件设置。

{% hint style="info" %}
如果你点击了 **稍后** 并且需要手动添加组件，请参见下面的手动组件设置。
{% endhint %}
{% endstep %}

{% step %}
**分配一个 Camera（如果不使用 Camera.main）**

选择 **ConvaiVisionRoot** GameObject（位于 `ConvaiRoomManager`）下。在 `CameraVisionFrameSource` 组件中，找到 **目标摄像机** 字段中。

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

<figure><img src="/files/ac34c7bb48871e5d56d4ef15a7e83503af861922" alt=""><figcaption></figcaption></figure>

默认的 **捕获预设** 为 **平衡** （1280 × 720，15 fps），适用于大多数用例。
{% endstep %}

{% step %}
**添加 Vision 调试预览并验证**

在任意场景 GameObject 上，点击 **添加组件** → **Convai/Vision/Vision 调试预览（仅编辑器）**.

<figure><img src="/files/90229f8dc121bfae0cd5e1d796e04aecabb1da9c" alt=""><figcaption></figcaption></figure>

按 **播放**。游戏视图中会出现一个覆盖层，显示实时摄像头画面和统计面板。房间连接后，FPS 计数器会递增，帧计数也会开始增加——此时角色已开始接收视觉上下文。

<figure><img src="/files/efb0ea40846e0570464bc740db8e18dcac0fc59e" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**成功检查**

Debug Preview 覆盖层显示实时图像，且 FPS 计数器不为 0。读取 `ConvaiVisionPublisher.IsPublishing` 在任意脚本中都会返回 `true`.
{% endhint %}

{% hint style="warning" %}
如果覆盖层一直为空白，或 FPS 计数器显示为 0，请确认 `ConvaiRoomManager.Connection Type` 被设置为 **视频** 并且房间已完全连接。请参见 [故障排查](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/vision/troubleshooting-and-diagnostics.md) 以进行逐步诊断。
{% endhint %}

***

## 手动组件设置

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

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

<figure><img src="/files/e969d94e4fd680a706f68678cd75462e5fd01cd2" alt=""><figcaption></figcaption></figure>

***

## 刚刚发生了什么

当你点击 **添加组件** 并按下 Play 时，发生了以下情况：

1. SDK 创建了一个 **ConvaiVisionRoot** 位于……下的子 GameObject `ConvaiRoomManager` 并添加了 `ConvaiVisionPublisher` 是位于 `CameraVisionFrameSource` 到其中。
2. `ConvaiRoomManager` 建立了一个 **视频** 与 Convai 后端的连接。
3. `ConvaiVisionPublisher` 检测到活动房间，并等待帧源就绪。
4. `CameraVisionFrameSource` 渲染所分配的摄像头（或 `Camera.main`）到一个 `RenderTexture` 并发出帧可用的信号。
5. `VisionPublishCoordinator` 应用了 `AutoCompatible` 发布策略——10 fps、750 kbps——并将纹理传递给视频管线。
6. 一个名为 `"unity-scene"` 的视频轨道已发布到 Convai 后端。 `IsPublishing` 变为 `true`.

从此开始，角色会同时接收场景摄像头的实时画面和音频对话，并将二者一起处理。

## 接下来是什么

* [帧源](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/vision/frame-sources.md) — 在桌面端切换到摄像头源，配置移动端摄像头权限，或设置 Meta Quest 透视功能。
* [发布与策略](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/vision/publishing-and-policies.md) — 调整帧率和码率，或切换到 Manual 策略，以明确控制何时开始发布。
* [调试预览](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/vision/debug-preview.md) — 自定义覆盖层的位置、大小和统计信息显示。
* [故障排除与诊断](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/vision/troubleshooting-and-diagnostics.md) — 如果有任何内容无法正常工作，请从这里开始。

## 结论

现在你已经拥有一个可用的 Vision 设置。SDK 会自动处理组件放置和运行时连线——角色会接收来自你的场景摄像头的实时画面，并能够对所见内容进行推理。请浏览上面的指南，以便根据你的目标平台和生产需求调整此设置。


---

# 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/unity-plugin-beta-overview/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.
