namespace VRTK.Examples { using UnityEngine; using VRTK.Controllables; using VRTK.Controllables.PhysicsBased; using VRTK.Controllables.ArtificialBased; public class ButtonReactor : MonoBehaviour { protected VRTK_PhysicsPusher buttonEvents; protected VRTK_ArtificialPusher artbuttonEvents; protected virtual void OnEnable() { buttonEvents = GetComponent(); if (buttonEvents != null) { buttonEvents.MaxLimitReached += MaxLimitReached; } artbuttonEvents = GetComponent(); if (artbuttonEvents != null) { artbuttonEvents.MaxLimitReached += MaxLimitReached; } } protected virtual void OnDisable() { if (buttonEvents != null) { buttonEvents.MaxLimitReached -= MaxLimitReached; } if (artbuttonEvents != null) { artbuttonEvents.MaxLimitReached -= MaxLimitReached; } } protected virtual void MaxLimitReached(object sender, ControllableEventArgs e) { VRTK_BaseControllable senderButton = sender as VRTK_BaseControllable; VRTK_Logger.Info(senderButton.name + " was pushed"); } } }