等待事件节点
概述
Wait For Event节点用于暂停图的执行,直到由Raise Event Node或宿主项目引发特定事件。事件名称可以在节点设置中配置,或通过输入端口动态提供。
该节点在您需要等待外部事件发生后再继续执行图形流程的场景中非常有用。例如,您可能需要等待用户点击按钮,或者等待API调用完成。
- 输入
- 输出
- 编辑器设置
输入项
标题 | 数据类型 | 描述 | 默认值 | 备注 |
---|---|---|---|---|
Data | any | Any data to be passed through the node. | N/A | This data will be outputted from the Data output port. |
输出
标题 | 数据类型 | 描述 | 备注 |
---|---|---|---|
Data | any | The data passed in through the Data input port. | If no data is passed into the Data input port, this port will not run. |
Event Data | any | The data associated with the event that was raised. | If the event has no associated data, this port will not run. |
编辑器设置
设置 | 描述 | 默认值 | 使用输入切换 | 输入数据类型 |
---|---|---|---|---|
Event Name | The name of the event to wait for. Must match the name of the event raised by the Raise Event Node or the host project. | continue | Yes | string |
示例1:等待由Raise Event节点触发的事件
- 创建一个Raise Event Node并将
Event Name
设置为myEvent
。 - 创建一个 Wait For Event 节点并将
Event Name
设置为myEvent
。 - 将一个文本节点连接到Raise Event Node的Data输入端口,文本内容为
Raise Event
。 - 将一个文本节点连接到Wait For Event节点的Data输入端口,文本内容为
Waited
。 - 将Raise Event节点和Wait For Event节点的输出端口连接到文本节点的输入端口。
- 运行图形。Wait For Event Node 将等待,直到 Raise Event Node 触发
myEvent
事件。 - 注意Wait For Event节点如何从
Event Data
输出端口输出Raise Event节点的数据。
错误处理
在正常情况下,Wait For Event节点不会出错。如果事件未被触发,该节点将无限期等待。
常见问题
问:我可以使用Wait For Event节点来等待多个事件吗?
A: 不,Wait For Event 节点只能等待单个事件。如果您需要等待多个事件,可以使用多个 Wait For Event 节点。
问:我能否使用Wait For Event节点来等待API调用触发的事件?
A: 是的,你可以使用HTTP Call Node来发起API调用,然后使用Wait For Event Node来等待API调用触发的事件。