Beispiel #1
0
 private static void InitializeEvetnsInterfaceCacheIfNeeded()
 {
     if (InterceptedEventsPreview.s_EventSystemInterfaces == null)
     {
         InterceptedEventsPreview.s_EventSystemInterfaces      = new List <Type>();
         InterceptedEventsPreview.s_PossibleEvents             = new List <GUIContent>();
         InterceptedEventsPreview.s_InterfaceEventSystemEvents = new Dictionary <Type, List <int> >();
         foreach (Type current in InterceptedEventsPreview.GetAccessibleTypesInLoadedAssemblies())
         {
             if (current.IsInterface)
             {
                 if (typeof(IEventSystemHandler).IsAssignableFrom(current))
                 {
                     InterceptedEventsPreview.s_EventSystemInterfaces.Add(current);
                     List <int>   list    = new List <int>();
                     MethodInfo[] methods = current.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                     for (int i = 0; i < methods.Length; i++)
                     {
                         MethodInfo methodInfo = methods[i];
                         list.Add(InterceptedEventsPreview.s_PossibleEvents.Count);
                         InterceptedEventsPreview.s_PossibleEvents.Add(new GUIContent(methodInfo.Name));
                     }
                     InterceptedEventsPreview.s_InterfaceEventSystemEvents.Add(current, list);
                 }
             }
         }
     }
 }
Beispiel #2
0
        protected static List <InterceptedEventsPreview.ComponentInterceptedEvents> GetEventsInfo(GameObject gameObject)
        {
            InterceptedEventsPreview.InitializeEvetnsInterfaceCacheIfNeeded();
            List <InterceptedEventsPreview.ComponentInterceptedEvents> list = new List <InterceptedEventsPreview.ComponentInterceptedEvents>();

            MonoBehaviour[] components = gameObject.GetComponents <MonoBehaviour>();
            int             i          = 0;
            int             num        = components.Length;

            while (i < num)
            {
                InterceptedEventsPreview.ComponentInterceptedEvents componentInterceptedEvents = null;
                MonoBehaviour monoBehaviour = components[i];
                if (!(monoBehaviour == null))
                {
                    Type type = monoBehaviour.GetType();
                    if (!InterceptedEventsPreview.s_ComponentEvents2.ContainsKey(type))
                    {
                        List <int> list2 = null;
                        if (typeof(IEventSystemHandler).IsAssignableFrom(type))
                        {
                            for (int j = 0; j < InterceptedEventsPreview.s_EventSystemInterfaces.Count; j++)
                            {
                                Type type2 = InterceptedEventsPreview.s_EventSystemInterfaces[j];
                                if (type2.IsAssignableFrom(type))
                                {
                                    if (list2 == null)
                                    {
                                        list2 = new List <int>();
                                    }
                                    list2.AddRange(InterceptedEventsPreview.s_InterfaceEventSystemEvents[type2]);
                                }
                            }
                        }
                        if (list2 != null)
                        {
                            componentInterceptedEvents = new InterceptedEventsPreview.ComponentInterceptedEvents();
                            componentInterceptedEvents.componentName     = new GUIContent(type.Name);
                            componentInterceptedEvents.interceptedEvents = (from index in list2
                                                                            orderby InterceptedEventsPreview.s_PossibleEvents[index].text
                                                                            select index).ToArray <int>();
                        }
                        InterceptedEventsPreview.s_ComponentEvents2.Add(type, componentInterceptedEvents);
                    }
                    else
                    {
                        componentInterceptedEvents = InterceptedEventsPreview.s_ComponentEvents2[type];
                    }
                    if (componentInterceptedEvents != null)
                    {
                        list.Add(componentInterceptedEvents);
                    }
                }
                i++;
            }
            return(list);
        }
        protected static List <InterceptedEventsPreview.ComponentInterceptedEvents> GetEventsInfo(GameObject gameObject)
        {
            InterceptedEventsPreview.InitializeEvetnsInterfaceCacheIfNeeded();
            List <InterceptedEventsPreview.ComponentInterceptedEvents> interceptedEventsList = new List <InterceptedEventsPreview.ComponentInterceptedEvents>();

            MonoBehaviour[] components = gameObject.GetComponents <MonoBehaviour>();
            int             index1     = 0;

            for (int length = components.Length; index1 < length; ++index1)
            {
                InterceptedEventsPreview.ComponentInterceptedEvents interceptedEvents = (InterceptedEventsPreview.ComponentInterceptedEvents)null;
                MonoBehaviour monoBehaviour = components[index1];
                if (!((UnityEngine.Object)monoBehaviour == (UnityEngine.Object)null))
                {
                    System.Type type = monoBehaviour.GetType();
                    if (!InterceptedEventsPreview.s_ComponentEvents2.ContainsKey(type))
                    {
                        List <int> source = (List <int>)null;
                        if (typeof(IEventSystemHandler).IsAssignableFrom(type))
                        {
                            for (int index2 = 0; index2 < InterceptedEventsPreview.s_EventSystemInterfaces.Count; ++index2)
                            {
                                System.Type eventSystemInterface = InterceptedEventsPreview.s_EventSystemInterfaces[index2];
                                if (eventSystemInterface.IsAssignableFrom(type))
                                {
                                    if (source == null)
                                    {
                                        source = new List <int>();
                                    }
                                    source.AddRange((IEnumerable <int>)InterceptedEventsPreview.s_InterfaceEventSystemEvents[eventSystemInterface]);
                                }
                            }
                        }
                        if (source != null)
                        {
                            interceptedEvents = new InterceptedEventsPreview.ComponentInterceptedEvents();
                            interceptedEvents.componentName     = new GUIContent(type.Name);
                            interceptedEvents.interceptedEvents = source.OrderBy <int, string>((Func <int, string>)(index => InterceptedEventsPreview.s_PossibleEvents[index].text)).ToArray <int>();
                        }
                        InterceptedEventsPreview.s_ComponentEvents2.Add(type, interceptedEvents);
                    }
                    else
                    {
                        interceptedEvents = InterceptedEventsPreview.s_ComponentEvents2[type];
                    }
                    if (interceptedEvents != null)
                    {
                        interceptedEventsList.Add(interceptedEvents);
                    }
                }
            }
            return(interceptedEventsList);
        }
 private static void InitializeEvetnsInterfaceCacheIfNeeded()
 {
     if (InterceptedEventsPreview.s_EventSystemInterfaces != null)
     {
         return;
     }
     InterceptedEventsPreview.s_EventSystemInterfaces      = new List <System.Type>();
     InterceptedEventsPreview.s_PossibleEvents             = new List <GUIContent>();
     InterceptedEventsPreview.s_InterfaceEventSystemEvents = new Dictionary <System.Type, List <int> >();
     foreach (System.Type inLoadedAssembly in InterceptedEventsPreview.GetAccessibleTypesInLoadedAssemblies())
     {
         if (inLoadedAssembly.IsInterface && typeof(IEventSystemHandler).IsAssignableFrom(inLoadedAssembly))
         {
             InterceptedEventsPreview.s_EventSystemInterfaces.Add(inLoadedAssembly);
             List <int> intList = new List <int>();
             foreach (MethodInfo method in inLoadedAssembly.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
             {
                 intList.Add(InterceptedEventsPreview.s_PossibleEvents.Count);
                 InterceptedEventsPreview.s_PossibleEvents.Add(new GUIContent(method.Name));
             }
             InterceptedEventsPreview.s_InterfaceEventSystemEvents.Add(inLoadedAssembly, intList);
         }
     }
 }
 public override void Initialize(UnityEngine.Object[] targets)
 {
     base.Initialize(targets);
     this.m_TargetEvents       = new Dictionary <GameObject, List <InterceptedEventsPreview.ComponentInterceptedEvents> >(((IEnumerable <UnityEngine.Object>)targets).Count <UnityEngine.Object>());
     this.m_InterceptsAnyEvent = false;
     for (int index = 0; index < targets.Length; ++index)
     {
         GameObject target = targets[index] as GameObject;
         List <InterceptedEventsPreview.ComponentInterceptedEvents> eventsInfo = InterceptedEventsPreview.GetEventsInfo(target);
         this.m_TargetEvents.Add(target, eventsInfo);
         if (eventsInfo.Any <InterceptedEventsPreview.ComponentInterceptedEvents>())
         {
             this.m_InterceptsAnyEvent = true;
         }
     }
 }
Beispiel #6
0
 public override void Initialize(UnityEngine.Object[] targets)
 {
     base.Initialize(targets);
     this.m_TargetEvents       = new Dictionary <GameObject, List <InterceptedEventsPreview.ComponentInterceptedEvents> >(targets.Count <UnityEngine.Object>());
     this.m_InterceptsAnyEvent = false;
     for (int i = 0; i < targets.Length; i++)
     {
         GameObject gameObject = targets[i] as GameObject;
         List <InterceptedEventsPreview.ComponentInterceptedEvents> eventsInfo = InterceptedEventsPreview.GetEventsInfo(gameObject);
         this.m_TargetEvents.Add(gameObject, eventsInfo);
         if (eventsInfo.Any <InterceptedEventsPreview.ComponentInterceptedEvents>())
         {
             this.m_InterceptsAnyEvent = true;
         }
     }
 }