VRChat Development: Difference between revisions
Jump to navigation
Jump to search
m (1 revision imported) |
|
(No difference)
|
Latest revision as of 17:24, 15 December 2022
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.