using UdonSharp; using UnityEngine; using VRC.SDKBase; using VRC.Udon; namespace VRCBilliardsCE.Packages.com.vrcbilliards.vrcbce.Runtime.Scripts.Components { /// ///

A timer, so you can handle callbacks in Udon without pain and suffering.

///

Instantiate this prefab then call _Set to use it.

///

Invalidate it with _Cancel.

///

Conclude it with _Trigger.

///
[AddComponentMenu("VRCBCE/Utilities/Timer")] public class Timer : UdonSharpBehaviour { private UdonBehaviour target; private string eventName; public void _Set(UdonBehaviour newTarget, string newName, float time) { target = newTarget; eventName = newName; SendCustomEventDelayedSeconds(nameof(_Trigger), time); } public void _Trigger() { if (!Utilities.IsValid(target)) { return; } target.SendCustomEvent(eventName); Destroy(gameObject); } public void _Cancel() { Destroy(gameObject); } } }