Udon Behaviour Array


Is it possible to create an array of type Udon Behaviour? I can create game object arrays fine and loop through them but I want to send custom network events to a couple of Udon behaviours from an interact event but don’t seem to be able to get it to work.


UdonBehaviourArray is not supported just yet. It’s being worked on.

For now you have to get the UdonBehaviours via a GameObject array instead.

Thanks. So a game object array with Udon Behaviours, something like this?

You have to get the UdonBehaviour component from the gameObject

GameObject Get Value -> GetComponent (UdonBehaviour) -> SendCustomEvent

Then the set value one has to have the gameobject and not the behaviour

Gotcha, thanks that sorted my issue out :slight_smile:

Could either one of you present a graph of how this would be set up? I don’t understand the steps in between GetComponent (UdonBehaviour) -> SendCustomEvent, as SendCustomEvent requires an instance and I can’t plug in the component into the instance slot. So how do you get the returned component back into an instance?

After extraneous testing and missing the obvious, I worked it out. You need to take the output from the GetComponent and assign it to an UdonBehaviour variable
For future refrence / until Udon Behaviour Arrays are implemented, if anybody needs reference, here’s the graph as well as the U# solution;

public UdonSharpBehaviour[] targetPrograms;
private UdonSharpBehaviour currentProgram;

void Interact()
    for (var i = 0; i < targetPrograms.Length; i++)
        currentProgram = targetPrograms[i];
1 Like