> For the complete documentation index, see [llms.txt](https://docs.febucci.com/text-animator-unity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.febucci.com/text-animator-unity/3.x-zh/da-zi-ji/dang-zi-mu-xian-shi-shi-bo-fang-sheng-yin.md).

# 当字母显示时播放声音

要在游戏中实现打字机音效，你可以订阅 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>
