using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; namespace BNG { /// /// Override this class to respond to various events that happen to this Grabbable /// [RequireComponent(typeof(Grabbable))] public abstract class GrabbableEvents : MonoBehaviour { protected Grabbable grab; protected Grabber thisGrabber; protected InputBridge input; protected virtual void Awake() { grab = GetComponent(); input = InputBridge.Instance; } /// /// Item has been grabbed by a Grabber /// /// public virtual void OnGrab(Grabber grabber) { thisGrabber = grabber; } /// /// Has been dropped from the Grabber /// public virtual void OnRelease() { } /// /// Called if this is the closest grabbable but wasn't in the previous frame /// /// public virtual void OnBecomesClosestGrabbable(ControllerHand touchingHand) { } /// /// Called if this is the closest grabbable but wasn't in the previous frame /// /// public virtual void OnBecomesClosestGrabbable(Grabber touchingGrabber) { } /// /// No longer closest grabbable. May need to disable highlight, ring, etc. /// /// public virtual void OnNoLongerClosestGrabbable(ControllerHand touchingHand) { } /// /// No longer closest grabbable. May need to disable highlight, ring, etc. /// /// public virtual void OnNoLongerClosestGrabbable(Grabber touchingGrabber) { } /// /// Fires if this is the closest remote grabbable but wasn't in the previous frame /// /// public virtual void OnBecomesClosestRemoteGrabbable(ControllerHand touchingHand) { } /// /// Fires if this is the closest remote grabbable but wasn't in the previous frame /// /// The Grabber that this object is valid for public virtual void OnBecomesClosestRemoteGrabbable(Grabber theGrabber) { } /// /// Fires if this was the closest remote grabbable last frame, but not this frame /// /// public virtual void OnNoLongerClosestRemoteGrabbable(ControllerHand touchingHand) { } /// /// Fires if this was the closest remote grabbable last frame, but not this frame /// /// The Grabber this object used to be associated with public virtual void OnNoLongerClosestRemoteGrabbable(Grabber theGrabber) { } /// /// Amount of Grip (0-1). Only fired if object is being held. /// /// 0 - 1 Open / Closed public virtual void OnGrip(float gripValue) { } /// /// Amount of Trigger being held down on the grabbed items controller. Only fired if object is being held. /// /// 0 - 1 Open / Closed public virtual void OnTrigger(float triggerValue) { } /// /// Fires if trigger was pressed down on this controller this frame, but was not pressed last frame. Only fired if object is being held. /// public virtual void OnTriggerDown() { } /// /// Fires if Trigger is not held down this frame /// public virtual void OnTriggerUp() { } /// /// Button 1 is being held down this frame but not last /// Oculus : Button 1 = "A" if held in Right controller."X" if held in Left Controller /// public virtual void OnButton1() { } /// /// Button 1 Pressed down this frame /// Oculus : Button 1 = "A" if held in Right controller."X" if held in Left Controller /// public virtual void OnButton1Down() { } /// /// Button 1 Released this frame /// Oculus : Button 1 = "A" if held in Right controller."X" if held in Left Controller /// public virtual void OnButton1Up() { } /// /// Button 2 is being held down this frame but not last /// Oculus : Button 2 = "B" if held in Right controller."Y" if held in Left Controller /// public virtual void OnButton2() { } /// /// Button 2 Pressed down this frame /// Oculus : Button 2 = "B" if held in Right controller."Y" if held in Left Controller /// public virtual void OnButton2Down() { } /// /// Button 2 Released this frame /// Oculus : Button 2 = "B" if held in Right controller."Y" if held in Left Controller /// public virtual void OnButton2Up() { } /// /// Grabbable has been successfully inserted into a SnapZone /// public virtual void OnSnapZoneEnter() { } /// /// Grabbable has been removed from a SnapZone /// public virtual void OnSnapZoneExit() { } } /// /// A UnityEvent with a float as a parameter /// [System.Serializable] public class FloatEvent : UnityEvent { } /// /// A UnityEvent with a 2 floats as parameters /// [System.Serializable] public class FloatFloatEvent : UnityEvent { } /// /// A UnityEvent with a Grabber as the parameter /// [System.Serializable] public class GrabberEvent : UnityEvent { } /// /// A UnityEvent with a Grabbable as the parameter /// [System.Serializable] public class GrabbableEvent : UnityEvent { } /// /// A UnityEvent with a RaycastHit as the parameter /// [System.Serializable] public class RaycastHitEvent : UnityEvent { } /// /// A UnityEvent with a Vector2 as a parameter /// [System.Serializable] public class Vector2Event : UnityEvent { } /// /// A UnityEvent with a Vector3 as a parameter /// [System.Serializable] public class Vector3Event : UnityEvent { } /// /// A UnityEvent with a Vector3 as a parameter /// [System.Serializable] public class PointerEventDataEvent : UnityEvent { } }