VRChat Development
A collection of useful Udon# scripts and examples.
Send Custom Event between objects
Object that is the SENDER of the event (On Interact)
using UdonSharp; using UnityEngine; using VRC.SDKBase; using VRC.Udon; public class VariableSetOnInteract : UdonSharpBehaviour { public UdonSharpBehaviour Target; override public void Interact() { Target.SendCustomEvent("ToggleObject"); } }
Object that receives the event (drag this object into the "Target" public variable of the sender in the inspector)
using UdonSharp; using UnityEngine; using VRC.SDKBase; using VRC.Udon; public class ToggleOffOn200 : UdonSharpBehaviour { public GameObject ToggleMe; public void ToggleObject() { ToggleMe.SetActive(!ToggleMe.activeSelf); } }
Drag the object to Toggle into the public variable "ToggleMe" in the inspector.