Ejemplo n.º 1
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);
        }
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            if (this.m_Styles == null)
            {
                this.m_Styles = new InterceptedEventsPreview.Styles();
            }
            Vector2 zero = Vector2.zero;
            int     num1 = 0;
            List <InterceptedEventsPreview.ComponentInterceptedEvents> targetEvent = this.m_TargetEvents[this.target as GameObject];

            using (List <InterceptedEventsPreview.ComponentInterceptedEvents> .Enumerator enumerator = targetEvent.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    foreach (int interceptedEvent in enumerator.Current.interceptedEvents)
                    {
                        GUIContent possibleEvent = InterceptedEventsPreview.s_PossibleEvents[interceptedEvent];
                        ++num1;
                        Vector2 vector2 = this.m_Styles.labelStyle.CalcSize(possibleEvent);
                        if ((double)zero.x < (double)vector2.x)
                        {
                            zero.x = vector2.x;
                        }
                        if ((double)zero.y < (double)vector2.y)
                        {
                            zero.y = vector2.y;
                        }
                    }
                }
            }
            r = new RectOffset(-5, -5, -5, -5).Add(r);
            int   num2     = Mathf.Max(Mathf.FloorToInt(r.width / zero.x), 1);
            int   num3     = Mathf.Max(num1 / num2, 1) + targetEvent.Count;
            float x        = r.x + Mathf.Max(0.0f, (float)(((double)r.width - (double)zero.x * (double)num2) / 2.0));
            float y        = r.y + Mathf.Max(0.0f, (float)(((double)r.height - (double)zero.y * (double)num3) / 2.0));
            Rect  position = new Rect(x, y, zero.x, zero.y);
            int   num4     = 0;

            using (List <InterceptedEventsPreview.ComponentInterceptedEvents> .Enumerator enumerator = targetEvent.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    InterceptedEventsPreview.ComponentInterceptedEvents current = enumerator.Current;
                    GUI.Label(position, current.componentName, this.m_Styles.componentName);
                    position.y += position.height;
                    position.x  = x;
                    foreach (int interceptedEvent in current.interceptedEvents)
                    {
                        GUIContent possibleEvent = InterceptedEventsPreview.s_PossibleEvents[interceptedEvent];
                        GUI.Label(position, possibleEvent, this.m_Styles.labelStyle);
                        if (num4 < num2 - 1)
                        {
                            position.x += position.width;
                        }
                        else
                        {
                            position.y += position.height;
                            position.x  = x;
                        }
                        num4 = (num4 + 1) % num2;
                    }
                    if ((double)position.x != (double)x)
                    {
                        position.y += position.height;
                        position.x  = x;
                    }
                }
            }
        }
 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;
 }