# 输入时等待动作

<mark style="color:默认;background-color:yellow;">**一旦打字机到达文本中的特定位置，你就可以执行动作**</mark>. *因此，只有在启用打字机时，动作才会生效。*

示例：等待 X 秒或等待玩家输入。

***

## 如何在文本中添加动作 <a href="#how-to-add-actions-in-your-text" id="how-to-add-actions-in-your-text"></a>

你可以通过使用富文本标签将动作添加到文本中。

动作的格式遵循以下公式：“`<actionID>`” 或 “`<actionID=attribute1,attribute2,...>`” 用于最终的参数/属性（就像事件/消息一样）。

{% hint style="warning" %}
动作标签不区分大小写， `<waitfor>` 和 `<waitFor>` 将产生相同的结果。
{% endhint %}

#### 参数 <a href="#parameters" id="parameters"></a>

动作支持多个参数，在 ‘`=`’ 符号后，并全部用 `逗号`.

示例： `<waitfor=1.5>` 或 `<playaudio=tada,laugh,dub>`

* ⚠️ 浮点数必须使用 `句点`，而不是 `逗号`.
  * ✔️ \<speed=0.5>
  * ❌ \<speed=0,5>

***

## 数据库 <a href="#databases" id="databases"></a>

与效果一样，你会发现动作被存储在各自的数据库中。你可以随意添加和移除，创建特定的动作，也可以 [通过 C# 编写自己的动作](/text-animator-unity/3.x-zh/bian-xie-zi-ding-yi-lei/bian-xie-zi-ding-yi-dong-zuo-c.md).

## 内置的 a <a href="#built-in-actions" id="built-in-actions"></a>

你可以在文本中使用以下内置动作。

<table data-view="cards"><thead><tr><th></th><th></th><th>标签</th><th>属性</th><th>示例</th><th data-hidden></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>等待秒数</strong></td><td>在继续显示文本之前等待 X 秒</td><td>waitfor</td><td>浮点数（等待时长）</td><td>&#x3C;waitfor=3></td><td><p></p><p></p></td><td></td><td></td></tr><tr><td><strong>等待输入</strong></td><td>等待玩家输入。具体文档在这里： <a data-mention href="/pages/29e0768ec210088cca2293820e8f96e2682e6298">/pages/29e0768ec210088cca2293820e8f96e2682e6298</a></td><td>waitinput</td><td>基于输入。 <a href="/pages/29e0768ec210088cca2293820e8f96e2682e6298">在此阅读更多</a>.</td><td>&#x3C;waitinput></td><td><p></p><p></p></td><td></td><td><a href="/pages/29e0768ec210088cca2293820e8f96e2682e6298">/pages/29e0768ec210088cca2293820e8f96e2682e6298</a></td></tr><tr><td><strong>速度</strong></td><td>将打字机速度乘以</td><td>speed</td><td>浮点数（速度倍率）</td><td>&#x3C;speed =2></td><td></td><td></td><td></td></tr></tbody></table>

## 组件动作

某些动作只有在场景中存在时才可用（你需要将它们创建为组件）。

<table data-view="cards"><thead><tr><th></th><th></th><th>标签</th><th>属性</th><th>示例</th><th data-hidden></th><th data-hidden></th></tr></thead><tbody><tr><td><strong>播放声音</strong></td><td>播放一个音频源（在检查器中引用），并等待其播放结束</td><td>psound</td><td>不适用</td><td>&#x3C;psound></td><td><p></p><p></p></td><td></td></tr></tbody></table>

### 本地动作

你可以使一个动作 *本地化*，这意味着只有当你将它们创建在打字机组件旁边时才会被识别。（仅适用于 **TextMeshPro**)

<figure><img src="/files/7e0b0ee1b4b9a4f47c8768d5a71d1831398bc328" alt=""><figcaption></figcaption></figure>

### 全局动作

只要将“全局可用”设置为开启，当前场景中任何正在打字的打字机都可以访问全局动作。


---

# 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/shu-ru-shi-deng-dai-dong-zuo.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.
