Add inputs and outputs to a Sub Graph
To pass data in and out of a Sub Graph, create input and output ports.
Create an input port
To create an input port, add a property to the blackboard of the Sub Graph. Follow these steps:
- Open the Sub Graph asset.
- In the Blackboard, click the + button and select the type of property you want to add.
- Drag the property from the Blackboard into the graph area to create a Property Node.
When you add the Sub Graph to a shader graph, the property appears as an input port on the Sub Graph Node.
Create an output port
To create an output port, add a port to the Output Node of the Sub Graph. Follow these steps:
- Open the Sub Graph asset.
- Select the Output node.
- In the Graph Inspector window, select the Node Settings tab.
- Under Inputs, select the Add (+) button.
- Use the dropdown to select the output type.
When you add the Sub Graph to a shader graph, the property appears as an output port on the Sub Graph node.
Avoid preview errors
The Preview window uses the first output port to generate the preview image. To avoid an error, ensure the first output port is one of the following data types:
BooleanFloatVector 2Vector 3Vector 4Matrix 2Matrix 3Matrix 4
For more information, refer to Custom Port Menu.