SubGraphs: Nested Graphs!

SubGraphs let you abstract out nodes from your node graph and makes your graphs more simpler, modular and reusable.

How to use SubGraphs

  1. Start by creating an SubGraph asset in your project folder:
    Create > VRChat > Udon > Udon Sub Graph Asset

  2. Create a UdonBehavior and create a normal Udon Graph Asset for it and then add a Sub Graph node and attach your Sub Graph Asset onto the node.

  3. Inside the Sub Graph create a custom event this should now allow your to connect noodles to your Sub Graph node in your Graph.

  4. You can pass data between your SubGraph and Graph using variables. Variables in the Graph must also be defined in the SubGraph (NOTE: This is subjected to change)

Example

Here’s the main Graph where we define an input called subGraphInput and output variable called subGraphResult which are defined in both Graph and SubGraph. (As I mentioned above this is subjected to change and may nolonger require redundant definitions in the SubGraph). We pass in a value in subGraphInput for the SubGraph to later use.

The SubGraph also has the same variables defined. We do this so we can access the variable names in the Get Variable and Set Variable. We can now get subGraphInput and in this case, we increment the value and set the result in subGraphResult for the Graph to access.

Note: I noticed that the compile button is missing for the Sub Graph probably because the compilation is done on the Graph asset instead.

I set the input variable to 2 so the result in the debug.log is 3
image
image

Download the example

4 Likes