//Check if we should execute the event on that handler protected bool ShouldSendEvent <T>(ITriggerEventHandler handler, bool includeDisabled) { var valid = handler is T; if (!valid) { return(false); } var behaviour = handler as Behaviour; if (behaviour != null && !includeDisabled) { return(behaviour.isActiveAndEnabled); } return(true); }
//Execute event protected void ExecuteEvent <T>(EventFunction <T> func, bool includeDisabled = false) where T : ITriggerEventHandler { for (int i = 0; i < this.m_TriggerEvents.Length; i++) { ITriggerEventHandler handler = this.m_TriggerEvents[i]; if (ShouldSendEvent <T>(handler, includeDisabled)) { func.Invoke((T)handler, PlayerInfo.gameObject); } } string eventID = string.Empty; if (this.m_CallbackHandlers.TryGetValue(typeof(T), out eventID)) { CallbackEventData triggerEventData = new CallbackEventData(); triggerEventData.AddData("Trigger", this); triggerEventData.AddData("Player", PlayerInfo.gameObject); triggerEventData.AddData("EventData", new PointerEventData(EventSystem.current)); base.Execute(eventID, triggerEventData); } }