VUdon - Events
VUdon Events ("UdonEvents") allows you to nearly natively implement UnityEvents into UdonSharp.
using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDKBase;
namespace Varneon.VUdon.UdonEvents
{
public class UdonEventTest : UdonSharpBehaviour
{
// Declare a serialized hidden field for the event handler singleton
[SerializeField, HideInInspector]
private UdonEventHandler udonEventHandler;
// Declare a serialized DataList field for each UdonEvent
[SerializeField, UdonEvent]
private DataList onPlayerTriggerEntered;
// Add UdonEventAttribute to the DataList fields for overriding
// the property drawer with the UdonEvent drawer
[SerializeField, UdonEvent]
private DataList onPlayerTriggerExited;
public override void OnPlayerTriggerEnter(VRCPlayerApi player)
{
// Invoke the UdonEvent's persistent calls stored in the DataList field
udonEventHandler.Invoke(onPlayerTriggerEntered);
}
public override void OnPlayerTriggerExit(VRCPlayerApi player)
{
// UdonEventHandler can invoke a list of calls by providing it the DataList
udonEventHandler.Invoke(onPlayerTriggerExited);
}
}
}
📦 UdonSharp scripts in a UPM package will need an assembly definition reference to
Varneon.VUdon.Events.Runtime
Import from Unitypackage:
- Download latest
com.varneon.vudon.events.unitypackage
from here- Import the downloaded .unitypackage into your Unity project