> 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` 是 MonoBehaviour，可直接在 Inspector 中连接事件——无需编写代码。对于脚本化响应和程序化控制， `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="/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="/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="/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="/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="/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="/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="/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="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/async-patterns.md">异步模式</a></td></tr></tbody></table>

### 下一步

先从 [会话事件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/session-events.md) 和 [角色事件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/character-events.md) 将 SDK 事件连接到你的场景逻辑，然后探索 [ConvaiManager API](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference/convaimanager-api.md) 用于连接控制的 [异步模式](/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.
