The Udon Node Graph is the default interface for creation of Udon programs. This section goes over how to use it. If you want to dive right into examples, take a look at the Readme file in the VRChat Examples folder that comes with the SDK.
You can open up the Udon Graph window using the Menu Item under VRChatSDK > Udon Graph, or by clicking the Open Graph button on an UdonBehaviour Component.
If you open the window through the Menu command, you'll see the welcome screen, which has a changelog and some settings. It will also show a button to re-open the last graph you had open if you have one.
The Flow of your graph defines which nodes will run, and the order in which they'll do it.
The triangles in the picture above are the Flow ports, and they trigger in order from left to right, following the noodles that connect them. To understand what is happening in Udon graphs and to make your own, follow the flow.
In the graph above:
- The Start event triggers when the world loads
- The Branch triggers next. It checks the value of its checkbox and then triggers either the True or False path.
- If the value is True, then we trigger the top node, which sends a Custom Event called "Hello".
- Otherwise, we will send a Custom Event called "Goodbye"
It's ok if you don't know Sending a Custom Event means yet. Learning to read the flow of a graph is the first step to understanding what they do.
Nodes are the boxes which represent the methods you can trigger. Building a graph consists of creating and connecting nodes together to create a program.
There are two main ways to create nodes - through Drag-and-Drop actions, and through search.
If you want to add interactivity to a GameObject or Component, you can drag and drop them from your hierarchy to the graph. For example, you can drag and drop a Light component by grabbing dragging from the 'Light' title onto the graph.
Creating nodes via Drag and Drop this way creates Variables that are tied to your GameObject or Component, so you'll see a new variable appear in the Variables window, and a node which is actually a "Get Variable" node which is automatically set up to get your new Component.
You can create variables of any type by pressing the + button in the Variables window. Then you can drag and drop the variable name onto the graph to create a "Get Variable" node, or hold the Ctrl key while dragging to make a "Set Variable" node.
Press the Spacebar to open up Quick Search, then type in the first few letters of the class you want to interact with.
This method of searching works best if you know Unity's basic classes and object types. There are other ways of searching, see: Searching for nodes
The graph automatically compiles in the background at regular variables. When this happens, you'll see a flash in the upper-right corner of your graph, and the Status box will turn green if things went well, or red if there's an issue. In either case, you can click on the Status box to see the Assembly Code that was generated, or the errors if there was a problem.
There are two ways to run the graphs in your scene before you upload them to VRChat.
You can use Unity's Play Button to run your scene directly in the editor to test out some graphs. This will work for some simple methods and logic, but the following items won't work as expected:
- Synced Variables & Networked Events
- The VRCPlayerAPI object - using stations, triggering Interact events, anything involving Avatars
Use the VRChat SDK Window to do Local Testing. This takes slightly longer as it bundles your content into an offline world and launches the actual VRChat client to give you an Avatar that can Interact with objects and VRCPlayerAPI requests.
To test Synced variables and NetworkEvents, you'll need two clients - you can use the 'Number of Clients' field to launch up to 8 local clients that will launch in a private test world. They will all have the same DisplayName, but they'll otherwise be recognized as separate players so you can test out your interactions.
Set Your Local Client Path
If 'Force Non-VR' doesn't work for you, then switch to the 'Settings' tab of the VRChat SDK Window and set your VRChat Client Path to point at your actual VRChat installation.
You will be able to Build & Test as soon as you make a VRChat Account. In order to publish a world so others can visit, you need to spend some time in VRChat - visit worlds, make some friends and get inspired!
Updated 4 months ago