Exemplo n.º 1
0
        public static bool Execute <T>(GameObject target, BaseEventData eventData, ExecuteEvents.EventFunction <T> functor) where T : IEventSystemHandler
        {
            List <IEventSystemHandler> element = ExecuteEvents.s_HandlerListPool.Get();

            ExecuteEvents.GetEventList <T>(target, (IList <IEventSystemHandler>)element);
            for (int index = 0; index < element.Count; ++index)
            {
                T handler;
                try
                {
                    handler = (T)element[index];
                }
                catch (Exception ex)
                {
                    Debug.LogException(new Exception(string.Format("Type {0} expected {1} received.", (object)typeof(T).Name, (object)element[index].GetType().Name), ex));
                    continue;
                }
                try
                {
                    functor(handler, eventData);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
            int count = element.Count;

            ExecuteEvents.s_HandlerListPool.Release(element);
            return(count > 0);
        }
Exemplo n.º 2
0
        public static bool CanHandleEvent <T>(GameObject go) where T : IEventSystemHandler
        {
            List <IEventSystemHandler> list = ExecuteEvents.s_HandlerListPool.Get();

            ExecuteEvents.GetEventList <T>(go, list);
            int count = list.Count;

            ExecuteEvents.s_HandlerListPool.Release(list);
            return(count != 0);
        }
Exemplo n.º 3
0
        public static bool Execute <T>(GameObject target, BaseEventData eventData, ExecuteEvents.EventFunction <T> functor) where T : IEventSystemHandler
        {
            List <IEventSystemHandler> list = ExecuteEvents.s_HandlerListPool.Get();

            ExecuteEvents.GetEventList <T>(target, list);
            int i = 0;

            while (i < list.Count)
            {
                T handler;
                try
                {
                    handler = (T)((object)list[i]);
                }
                catch (Exception innerException)
                {
                    IEventSystemHandler eventSystemHandler = list[i];
                    Debug.LogException(new Exception(string.Format("Type {0} expected {1} received.", typeof(T).Name, eventSystemHandler.GetType().Name), innerException));
                    goto IL_8F;
                }
                goto Block_2;
IL_8F:
                i++;
                continue;
Block_2:
                try
                {
                    functor(handler, eventData);
                }
                catch (Exception exception)
                {
                    Debug.LogException(exception);
                }
                goto IL_8F;
            }
            int count = list.Count;

            ExecuteEvents.s_HandlerListPool.Release(list);
            return(count > 0);
        }