> 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# 集成方式。 `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>通过 relay 组件或类型化 C# hub 获取连接状态、错误、空闲警告和参与者变更。</td><td><a href="/pages/6f90d2d448d0f65990aa0f30d6e9fd76263eea2e">/pages/6f90d2d448d0f65990aa0f30d6e9fd76263eea2e</a></td></tr><tr><td><strong>角色事件</strong><br>通过 relay 组件或类型化 C# hub 获取语音、情绪、转录、轮次生命周期和动作事件。</td><td><a href="/pages/d5d0bda9517e2ebcad589dcd94370c3d5b9a2130">/pages/d5d0bda9517e2ebcad589dcd94370c3d5b9a2130</a></td></tr><tr><td><strong>转录 API</strong><br>用于查询并订阅实时内存转录时间线的拉取式门面。</td><td><a href="/pages/1a33f148fac3ddf7352a86abb1f67ce91973142c">/pages/1a33f148fac3ddf7352a86abb1f67ce91973142c</a></td></tr><tr><td><strong>角色与玩家 API</strong><br>完整的方法、属性和事件参考，适用于 <code>ConvaiCharacter</code> 和 <code>ConvaiPlayer</code>.</td><td><a href="/pages/0b05353dc271e9a67f022bad20df0f61e55c2176">/pages/0b05353dc271e9a67f022bad20df0f61e55c2176</a></td></tr><tr><td><strong>ConvaiManager API</strong><br>SDK 入口点——连接控制、门面访问器、会话所有权和服务发现。</td><td><a href="/pages/837e187dde6ef107490d678933eda069ab0635b1">/pages/837e187dde6ef107490d678933eda069ab0635b1</a></td></tr><tr><td><strong>音频 API</strong><br>麦克风静音、按角色音频控制、音频播放解锁和监听状态。</td><td><a href="/pages/bb7cdb69415400d0bfcff2641441af4bd4480284">/pages/bb7cdb69415400d0bfcff2641441af4bd4480284</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="/pages/15b65578023dcda7a39e06f4214cfae613ce3123">/pages/15b65578023dcda7a39e06f4214cfae613ce3123</a></td></tr><tr><td><strong>异步模式</strong><br>消费 SDK 异步类型的六种模式：async/await、协程、链式调用、进度、取消和流。</td><td><a href="/pages/66f1c88f2864611c5d967825822213f8fa8fa8fa">/pages/66f1c88f2864611c5d967825822213f8fa8fa8fa</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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/scripting-reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
