References
Last updated
Last updated
You can use a reference node to pass an object reference into a graph. For example, if you want to create an AFX graph that moves a cube in the scene, you can use a Transform Reference
node to pass a reference to the cube into the AFX graph.
You can also use reference nodes to pass objects from a parent graph into a subgraph. For more information, see Adding inputs to an AFX subgraph.
Each reference node has a field in which you can enter a reference name. A corresponding property will then be added to the AFX Object Reference Manager component when you attach the graph to a game object. As shown in the following image:
Open the graph in which you want to add a reference node.
Right-click on the graph canvas to open the node dictionary, and then select the reference node that you want to use. For information about the available nodes, see Reference.
In the reference node, enter a name for the reference.
Select the game object that the AFX graph is assigned to.
In the Inspector panel, assign an appropriate object to the reference property that was added to the AFX Object Reference Manager component.
If you use the same reference name in different reference nodes, they will refer the same object. However, this applies only to reference nodes that are within the same graph.
For example, in the following image both transform reference nodes have the same reference name (cube_ref
), and so refer to the same object. This can be useful in large graphs where the alternative would be long connections between nodes.
Variable components provide important, complimentary functionality to reference nodes. You can add a variable component to a game object, and then use it as a reference in an AFX graph. The variable type of the component must match the variable type of the reference node.
Multiple AFX graphs can reference the same variable component. You can use this functionality to pass variable values between AFX graphs.
To add a variable component, complete the following steps:
In the Hierarchy panel, select the game object to which you want to add a variable component.
In the Inspector panel, select Add Component.
In the search field, enter component
.
Select the variable component that you want to add.