Example #1
0
        //You don't currently have to do this as the BaseEventData can be retrieved, init'ed and
        //  fired from itself
        public void TriggerEvent <T>(BaseEventData e) where T : BaseEventData, new()
        {
            EventManagerChannel id = GetViaType <T>(false);

            if (id != null)
            {
                id.Invoke(e);
            }
            else
            {
                Debug.LogWarning("Event: " + e.GetType() + " has not been registered");
            }
        }
Example #2
0
        public void RemoveListener <T>(EventDelegate <T> del) where T : BaseEventData, new()
        {
            EventManagerChannel id = GetViaType <T>(false);

            if (id != null)
            {
                id.Remove(del);
            }
            else
            {
                Debug.LogWarning("Event: " + typeof(T) + " has not been registered");
            }
        }
Example #3
0
        private EventManagerChannel GetViaType <T>(bool createIfNull) where T : BaseEventData, new()
        {
            EventManagerChannel retval = null;

            delegates.TryGetValue(typeof(T), out retval);

            if (createIfNull && retval == null)
            {
                retval = new EventManagerChannel();
                retval.Init <T>();
                delegates[typeof(T)] = retval;
            }

            return(retval);
        }