/VUdon-Events

UnityEvents for UdonSharp

Primary LanguageC#MIT LicenseMIT

⚠️ VUdon Events is heavily experimental and may break without a notice! Use at your own risk.

VUdon - Events GitHub Repo stars GitHub all releases GitHub tag (latest SemVer)

VUdon Events ("UdonEvents") allows you to nearly natively implement UnityEvents into UdonSharp.

image

How to use VUdon Events

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

image

Installation

Import from Unitypackage:

  1. Download latest com.varneon.vudon.events.unitypackage from here
  2. Import the downloaded .unitypackage into your Unity project

Developed by Varneon with ♥️

Twitter Follow YouTube Channel Subscribers GitHub followers