> 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/scripting-reference.md).

# 脚本参考

Convai Unity SDK C# 脚本 API 参考文档——事件、转录文本、音频控制和异步操作模式。

Convai Unity SDK 为 C# 集成提供了两种互为补充的方式。 `ConvaiSessionEventRelay`, `ConvaiCharacterEventRelay`和 `ConvaiTranscriptEventRelay` 都是可直接在 Inspector 中连接事件的 MonoBehaviour，无需编写代码。对于脚本化响应和程序化控制， `ConvaiEvents` 类型化事件中心以及各组件的 C# API 可供任何脚本完整访问。这两种方式监听的是同一组底层 SDK 事件，可以自由组合使用。

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>会话事件</strong><br>通过中继组件或类型化 C# 事件中心处理连接状态、错误、空闲警告和参与者变更。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/session-events.md">会话事件</a></td></tr><tr><td><strong>角色事件</strong><br>通过中继组件或类型化 C# 事件中心处理语音、情绪、转录文本、轮次生命周期和操作事件。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/character-events.md">角色事件</a></td></tr><tr><td><strong>转录 API</strong><br>基于拉取的接口，用于查询和订阅实时的内存转录时间线。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/transcript-api.md">转录 API</a></td></tr><tr><td><strong>角色与玩家 API</strong><br>完整的方法、属性和事件参考，涵盖 <code>ConvaiCharacter</code> 和 <code>ConvaiPlayer</code>.</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/character-and-player-api.md">角色和玩家 API</a></td></tr><tr><td><strong>ConvaiManager API</strong><br>SDK 入口点——连接控制、接口访问器、对话所有权和服务发现。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/convaimanager-api.md">ConvaiManager API</a></td></tr><tr><td><strong>音频 API</strong><br>麦克风静音、单个角色的音频控制、音频播放解锁和监听状态。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/audio-api.md">音频 API</a></td></tr><tr><td><strong>操作与流类型</strong><br>类型参考，涵盖 <code>IConvaiOperation&#x3C;T></code>, <code>IConvaiStream&#x3C;T></code>, <code>ConvaiError</code>, <code>Unit</code>以及状态枚举。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/operation-and-stream-types.md">操作和流类型</a></td></tr><tr><td><strong>异步模式</strong><br>使用 SDK 异步类型的六种模式：async/await、协程、链式调用、进度跟踪、取消和流。</td><td><a href="https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/async-patterns.md">异步模式</a></td></tr></tbody></table>

### 后续步骤

从 [会话事件](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/session-events.md) 和 [角色事件](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/character-events.md) 入手，将 SDK 事件连接到场景逻辑；然后了解 [ConvaiManager API](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/convaimanager-api.md) 以控制连接，并参阅 [异步模式](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/async-patterns.md) 页面，了解如何使用这些功能。


---

# 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/scripting-reference.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.
