> 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/utilities/convai-ui-prefabs.md).

# 预构建 UI 预制体

Convai UI 预制体——利用可直接使用的 UI 元素来进行 Convai 集成。

我们提供多种开箱即用的 UI 选项，用于显示角色和用户的转录文本，玩家可以与 Convai 插件一起使用。你可以使用并自定义这些预制体。

ConvaiNPC 和 ConvaiGRPCAPI 脚本会查找带有 Convai Chat UI Handler 组件的 GameObject，并将任何转录文本发送到该脚本，以便显示在屏幕上。

## UI 类型

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FXfzLV1d0XyU0Grnqa2l2%2Fimage.png?alt=media&amp;token=4bc187f0-8f9f-4945-8351-444780395081" alt=""><figcaption></figcaption></figure>

### 聊天框

**预制体名称**：Convai Transcript Canvas - 聊天

用户和角色的转录文本会依次显示在一个可滚动的聊天框中。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2F0Zk1wAnyf5RXQWUC29yT%2Fimage.png?alt=media&amp;token=42eaba3e-777f-4bff-97cb-255670042ac7" alt=""><figcaption></figcaption></figure>

### 字幕

**预制体名称**：Convai Transcript Canvas - 字幕

用户和角色的转录文本会像字幕一样显示在底部。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FvIdkJSh5EIAJexSXdPoW%2Fimage.png?alt=media&amp;token=fe410464-b8c1-4b3b-8cf2-07db5427fc02" alt=""><figcaption></figcaption></figure>

### 问答

**预制体名称**：Convai Transcript Canvas - 问答

用户的转录文本显示在顶部，而角色的转录文本显示在底部。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FLQ4lVgHRluh0oxsTIhFv%2Fimage.png?alt=media&amp;token=d35b95ec-e0eb-4ccc-a681-9b7daabdb782" alt=""><figcaption></figcaption></figure>

### 移动端优化的 UI 样式

**预制体名称**：Convai Transcript Canvas - 移动端字幕

与 [#subtitle](#subtitle "mention") UI 相同。包含一个可按住的按钮，供用户说话。非常适合屏幕纵向模式。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FLgCKLMFp4GgiUSdozGCK%2Fimage.png?alt=media&amp;token=6a706b9b-8996-4c2b-ba2d-00424556cef5" alt="" width="328"><figcaption></figcaption></figure>

**预制体名称**：Convai Transcript Canvas - 移动端问答

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FjONNuodDLgthlr71LxkY%2Fimage.png?alt=media&amp;token=0b8508a2-e217-48e4-a6ab-3452b7770c9c" alt="" width="331"><figcaption></figcaption></figure>

**预制体名称**：Convai Transcript Canvas - 移动端聊天

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FpqxJrTapBuD10nH5IkG5%2Fimage.png?alt=media&amp;token=1e6f74cf-76c6-4a9c-8a7e-e7eb7fcace37" alt="" width="327"><figcaption></figcaption></figure>

## [Convai Chat UI Handler 组件](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/utilities/transcript-ui-system.md)

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FeSFdCu4aXPAINsalZULd%2Fimage%202.png?alt=media&amp;token=3cd13959-3b74-4f9c-bb65-60ce7b946fb5" alt=""><figcaption></figcaption></figure>

### 需要了解的函数

<table><thead><tr><th width="265"></th><th></th></tr></thead><tbody><tr><td>发送角色文本</td><td>一个公共函数，用于发送一段文本，以显示为角色转录文本，并附带说出该文本的角色名称。</td></tr><tr><td>发送用户文本</td><td>一个公共函数，用于发送一段文本，以显示为用户转录文本。</td></tr></tbody></table>


---

# 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/unity-plugin/utilities/convai-ui-prefabs.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.
