public static void RemoveListener(UIEventKey key, Action <IFayvitUiEvent> acao)
        {
            List <Action <IFayvitUiEvent> > callbackList;

            if (_eventDictionary.TryGetValue(key, out callbackList))
            {
                callbackList.Remove(acao);
            }
        }
        public static void AddListener(UIEventKey key, Action <IFayvitUiEvent> callback)
        {
            List <Action <IFayvitUiEvent> > callbackList;

            if (!_eventDictionary.TryGetValue(key, out callbackList))
            {
                callbackList = new List <Action <IFayvitUiEvent> >();
                _eventDictionary.Add(key, callbackList);
            }

            callbackList.Add(callback);
        }
        public static void Publish(UIEventKey key, IFayvitUiEvent umEvento = null)
        {
            List <Action <IFayvitUiEvent> > callbackList;

            if (_eventDictionary.TryGetValue(key, out callbackList))
            {
                //Debug.Log(callbackList.Count+" : "+umEvento.Sender+" : "+key);

                foreach (var e in callbackList)
                {
                    if (e != null)
                    {
                        e(umEvento);
                    }
                    else
                    {
                        Debug.LogWarning("Event agregator chamou uma função nula na key: " + key +
                                         "\r\n Geralmente ocorre quando o objeto do evento foi destruido sem se retirar do listener");
                    }
                }
            }
        }
Example #4
0
 public FayvitUiEvent(UIEventKey key, params object[] o)
 {
     Key           = key;
     MySendObjects = o;
 }