using UnityEngine; using UnityAtoms.BaseAtoms; namespace UnityAtoms.MonoHooks { /// /// Base class for all `MonoHook`s of type `AtomEventBase`. /// [EditorIcon("atom-icon-delicate")] public abstract class VoidHook : MonoBehaviour { /// /// The Event /// [SerializeField] protected AtomEventBase _event; /// /// Event including a GameObject reference. /// [SerializeField] protected GameObjectEvent _eventWithGameObjectReference; /// /// Selector function for the Event `EventWithGameObjectReference`. Makes it possible to for example select the parent GameObject and pass that a long to the `EventWithGameObjectReference`. /// [SerializeField] protected GameObjectGameObjectFunction _selectGameObjectReference; protected void OnHook() { if (_event != null) { _event.Raise(); } if (_eventWithGameObjectReference != null) { _eventWithGameObjectReference.Raise(_selectGameObjectReference != null ? _selectGameObjectReference.Call(gameObject) : gameObject); } } } }