# 显示字母时播放声音

要在游戏中实现打字机音效，你可以订阅 Typewriter 的 “`OnCharacterVisible`” 事件并根据该事件播放音效。

该事件会传递一个 “char” 作为参数，因此你也可以根据不同的字母播放不同的音效。

*附注：该事件在遇到空格时也会触发，因此请根据你偏好的字符类型来决定是否播放音效。*

***

### 示例包 <a href="#example-package" id="example-package"></a>

例如，你可以安装位于 “Extra” 文件夹中的 “TypeWriter Sounds” 包并查看其实现。

![](/files/cff5d1252932b10bdc133b1d9921f9729a345368)

<table><thead><tr><th width="221">变量</th><th>说明</th></tr></thead><tbody><tr><td><code>来源</code></td><td>播放音效的主要音频源</td></tr><tr><td><code>MinSoundDelay</code></td><td>在播放下一个音效之前必须经过的最短时间</td></tr><tr><td><code>中断之前的音效</code></td><td>如果为真，之前的音频将被停止</td></tr><tr><td><code>随机序列</code></td><td>如果为真，下一个要播放的音频剪辑将从 “Sounds” 数组中随机选择。如果为假，音效将按顺序播放</td></tr><tr><td><code>音效</code></td><td>要播放的打字机音效</td></tr></tbody></table>


---

# Agent Instructions: 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:

```
GET https://docs.febucci.com/text-animator-unity/3.x-zh/da-zi-ji/xian-shi-zi-mu-shi-bo-fang-sheng-yin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
