using System; using UnityEngine; using UnityEngine.Events; namespace Leap.Unity { public class Detector : MonoBehaviour { public bool IsActive { get { return this._isActive; } } public virtual void Activate() { if (!this.IsActive) { this._isActive = true; this.OnActivate.Invoke(); } } public virtual void Deactivate() { if (this.IsActive) { this._isActive = false; this.OnDeactivate.Invoke(); } } private bool _isActive; [Tooltip("Draw this detector's Gizmos, if any. (Gizmos must be on in Unity edtor, too.)")] public bool ShowGizmos = true; [Tooltip("Dispatched when condition is detected.")] public UnityEvent OnActivate; [Tooltip("Dispatched when condition is no longer detected.")] public UnityEvent OnDeactivate; protected Color OnColor = Color.green; protected Color OffColor = Color.red; protected Color LimitColor = Color.blue; protected Color DirectionColor = Color.white; protected Color NormalColor = Color.gray; } }