> 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/scene-metadata/quick-start.md).

# 场景元数据快速开始

为 Unity 场景添加物体感知功能，让 Convai 角色从连接时起就能在对话中提及已命名的物体。

设置场景元数据，让 Convai 角色了解场景中的命名对象。完成后，角色就能知道场景中有哪些对象，并在对话中提及它们——整个过程都可在 Inspector 中完成。

### 前提条件

开始之前，请确认：

* [ ] A `ConvaiCharacter` 已添加到场景中，并且在 Play Mode 下能响应语音

### 为场景对象添加标签并收集它们

{% stepper %}
{% step %}

#### 将 ConvaiObjectMetadata 添加到场景对象

在场景中选择一个你希望 AI 角色了解的 GameObject，例如一件设备、灭火器、门或展品。在 Inspector 中，点击 **添加组件**，然后浏览到 **Convai → World Object** 或搜索 `Convai Object Metadata`.

“ **对象名称** ”字段会自动填入 GameObject 的名称。如果该名称不够清晰易懂，请将其改为便于阅读的标签。例如，将 `Prop_FireExt_01` 改为 `Fire Extinguisher`.

你也可以在 **对象描述** 中填写一到两句客观描述，说明对象是什么、位于何处以及有哪些重要属性。请控制在 200 个字符以内。

{% hint style="warning" %}
**对象名称** 为必填项。若留空，该对象将不会包含在负载中——即使 `Is Registered` 显示为 `true`，该对象也不会传送到 Convai。
{% endhint %}
{% endstep %}

{% step %}

#### 将 ConvaiObjectMetadata 添加到其余对象

将 `ConvaiObjectMetadata` 添加到 AI 需要了解的每个其他对象上。无需将它添加到每个 GameObject，只需添加到与 AI 对话相关的对象即可。

每个组件启用时都会自动向 `ConvaiMetadataRegistry` 注册。无需手动连接或调用注册方法。
{% endstep %}

{% step %}

#### 添加 ConvaiSceneMetadataCollector 并启用自动收集

已注册的对象会在角色就绪后自动传送给角色，即使不添加此组件也是如此—— `ConvaiSceneMetadataCollector` 是可选的。现在添加它，可在下一步中使用 **记录统计信息** 进行确认，也便于之后手动重新收集；完整的数据传递流程请参阅 [场景元数据的工作原理](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/scene-metadata/how-scene-metadata-works.md) 。

在场景中的任意 GameObject 上，点击 **添加组件** 并搜索 `Convai Scene Metadata Collector`。将它放在与 `ConvaiManager` 相同的 GameObject 上，是一种便于组织管理的做法。

在 Inspector 中，启用 **启动时收集**。这会告知收集器：房间会话连接时自动发送完整的元数据负载。

保持 **日志统计** 处于启用状态——每次收集时，它都会在 Console 中写入一条记录，显示对象数量和耗时，以确认一切正常。

`ConvaiSceneMetadataCollector` 会在启动时自动查找 `ConvaiManager` 并解析其依赖项——无需手动连接。
{% endstep %}

{% step %}

#### 进入 Play Mode 并验证

点击 Play。房间连接后，收集器会自动运行。检查 Console，确认其中有类似以下内容的调试记录：

```
[ConvaiSceneMetadataCollector] Collected 4 metadata objects in 0.0010s. Registry stats: 4 total, 4 valid, 0 invalid
```

这表示负载已组装并发送至 Convai。向角色提出一个需要了解场景的问题进行测试，例如：“这一层有哪些设备？”或“你能描述一下出口附近有什么吗？”
{% endstep %}
{% endstepper %}

{% hint style="success" %}
角色会根据你输入的名称和描述提供相应信息。场景元数据已正常运行。
{% endhint %}

### 后续步骤

{% content-ref url="/pages/b55fe13afe8f10f3ca27eec09be22c5bd975a884" %}
[场景元数据组件参考](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/scene-metadata/component-reference.md)
{% endcontent-ref %}

{% content-ref url="/pages/f6f3f3d88a3636afea1b0c8774162c2014fba780" %}
[排查场景元数据问题](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/scene-metadata/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 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/features/scene-metadata/quick-start.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.
