Expression node
Use the Expression node to specify a complex mathematical expression as a string instead of using multiple Math nodes.
Input ports
The number and type of input ports automatically adjust to the values of the node controls. Unity adds an input port for each variable in the expression in the text field.
Output port
| Name | Type | Description |
|---|---|---|
| Out | Depends on the selected Type in the node controls. | The value resulting from the expression specified in the text field. |
Controls
| Name | Description |
|---|---|
| Type | Specifies the data type to use for all input and output ports of the node. The options are:
|
| (Text field) | Use this field to specify the mathematical expression. The field supports the following:
|
Example
If you specify the expression:
a + b * c / 2
- Unity adds three input ports to the node: A, B, and C.
- If you input 1, 2, and 10, the node calculates
1 + 2 * 10 / 2and outputs the result to the Out port.
Note: If you use Shader Graph math nodes instead, the example requires three separate nodes: Divide, Multiply, and Add.