评估节点

概述
评估节点对输入值执行数学运算并输出结果。它支持多种运算,包括加法、减法、乘法、除法、指数运算、取模、绝对值和取反。
- 输入
- 输出
- 编辑器设置
输入项
| 标题 | 数据类型 | 描述 | 默认值 | 备注 |
|---|---|---|---|---|
| A | number | The first operand for the operation. | (Required) | The input will be coerced into a number if it is not a number. |
| B | number | The second operand for the operation. | (Required for binary operators) | The input will be coerced into a number if it is not a number. |
输出
| 标题 | 数据类型 | 描述 | 备注 |
|---|---|---|---|
| Output | number | The result of the operation. |
编辑器设置
| 设置 | 描述 | 默认值 | 使用输入切换 | 输入数据类型 |
|---|---|---|---|---|
| Operation | The operation to perform on the input values. Options include +, -, *, /, ^, %, abs, and negate. | + | Yes | string |
示例1:执行简单的加法运算
- 创建一个Evaluate节点并将
Operation设置为+。 - 创建两个Number节点,将它们的值分别设置为
2和3。 - 将数值节点连接到Evaluate节点的
A和B输入端口。 - 运行图形。Evaluate Node 的输出应为
5。

错误处理
如果操作失败(例如,如果您尝试除以零),Evaluate节点将会报错。
常见问题
问:如果我想根据输入执行不同的操作怎么办?
A: 您可以使用Operation输入端口根据输入动态更改操作。输入将被强制转换为字符串,并且必须匹配支持的操作之一。