public override void OnPreviewGUI(Rect r, GUIStyle background)
 {
   if (Event.current.type != EventType.Repaint || this.m_Info == null || this.m_Info.Count == 0)
     return;
   if (this.m_Styles == null)
     this.m_Styles = new NetworkInformationPreview.Styles();
   Vector2 vector2 = new Vector2(140f, 16f);
   Vector2 maxNameLabelSize = this.GetMaxNameLabelSize();
   r = new RectOffset(-5, -5, -5, -5).Add(r);
   float x = r.x + 10f;
   float y1 = r.y + 10f;
   Rect position1 = new Rect(x, y1, vector2.x, vector2.y);
   Rect position2 = new Rect(vector2.x, y1, maxNameLabelSize.x, maxNameLabelSize.y);
   using (List<NetworkInformationPreview.NetworkIdentityInfo>.Enumerator enumerator = this.m_Info.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       NetworkInformationPreview.NetworkIdentityInfo current = enumerator.Current;
       GUI.Label(position1, current.name, this.m_Styles.labelStyle);
       GUI.Label(position2, current.value, this.m_Styles.componentName);
       position1.y += position1.height;
       position1.x = x;
       position2.y += position2.height;
     }
   }
   float y2 = position1.y;
   if (this.m_Behaviours == null || this.m_Behaviours.Count <= 0)
     return;
   Vector2 behaviourLabelSize = this.GetMaxBehaviourLabelSize();
   Rect position3 = new Rect(x, position1.y + 10f, behaviourLabelSize.x, behaviourLabelSize.y);
   GUI.Label(position3, new GUIContent("Network Behaviours"), this.m_Styles.labelStyle);
   position3.x += 20f;
   position3.y += position3.height;
   using (List<NetworkInformationPreview.NetworkBehaviourInfo>.Enumerator enumerator = this.m_Behaviours.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       NetworkInformationPreview.NetworkBehaviourInfo current = enumerator.Current;
       if (!((Object) current.behaviour == (Object) null))
       {
         if (current.behaviour.enabled)
           GUI.Label(position3, current.name, this.m_Styles.componentName);
         else
           GUI.Label(position3, current.name, this.m_Styles.disabledName);
         position3.y += position3.height;
         y2 = position3.y;
       }
     }
   }
   if (this.m_Identity.observers != null && this.m_Identity.observers.Count > 0)
   {
     Rect position4 = new Rect(x, y2 + 10f, 200f, 20f);
     GUI.Label(position4, new GUIContent("Network observers"), this.m_Styles.labelStyle);
     position4.x += 20f;
     position4.y += position4.height;
     foreach (NetworkConnection observer in this.m_Identity.observers)
     {
       GUI.Label(position4, observer.address + ":" + (object) observer.connectionId, this.m_Styles.componentName);
       position4.y += position4.height;
       y2 = position4.y;
     }
   }
   if (this.m_Identity.clientAuthorityOwner == null)
     return;
   GUI.Label(new Rect(x, y2 + 10f, 400f, 20f), new GUIContent("Client Authority: " + (object) this.m_Identity.clientAuthorityOwner), this.m_Styles.labelStyle);
 }
Exemple #2
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type != EventType.Repaint || this.m_Info == null || this.m_Info.Count == 0)
            {
                return;
            }
            if (this.m_Styles == null)
            {
                this.m_Styles = new NetworkInformationPreview.Styles();
            }
            Vector2 vector2          = new Vector2(140f, 16f);
            Vector2 maxNameLabelSize = this.GetMaxNameLabelSize();

            r = new RectOffset(-5, -5, -5, -5).Add(r);
            float x         = r.x + 10f;
            float y1        = r.y + 10f;
            Rect  position1 = new Rect(x, y1, vector2.x, vector2.y);
            Rect  position2 = new Rect(vector2.x, y1, maxNameLabelSize.x, maxNameLabelSize.y);

            using (List <NetworkInformationPreview.NetworkIdentityInfo> .Enumerator enumerator = this.m_Info.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    NetworkInformationPreview.NetworkIdentityInfo current = enumerator.Current;
                    GUI.Label(position1, current.name, this.m_Styles.labelStyle);
                    GUI.Label(position2, current.value, this.m_Styles.componentName);
                    position1.y += position1.height;
                    position1.x  = x;
                    position2.y += position2.height;
                }
            }
            float y2 = position1.y;

            if (this.m_Behaviours == null || this.m_Behaviours.Count <= 0)
            {
                return;
            }
            Vector2 behaviourLabelSize = this.GetMaxBehaviourLabelSize();
            Rect    position3          = new Rect(x, position1.y + 10f, behaviourLabelSize.x, behaviourLabelSize.y);

            GUI.Label(position3, new GUIContent("Network Behaviours"), this.m_Styles.labelStyle);
            position3.x += 20f;
            position3.y += position3.height;
            using (List <NetworkInformationPreview.NetworkBehaviourInfo> .Enumerator enumerator = this.m_Behaviours.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    NetworkInformationPreview.NetworkBehaviourInfo current = enumerator.Current;
                    if (!((Object)current.behaviour == (Object)null))
                    {
                        if (current.behaviour.enabled)
                        {
                            GUI.Label(position3, current.name, this.m_Styles.componentName);
                        }
                        else
                        {
                            GUI.Label(position3, current.name, this.m_Styles.disabledName);
                        }
                        position3.y += position3.height;
                        y2           = position3.y;
                    }
                }
            }
            if (this.m_Identity.observers != null && this.m_Identity.observers.Count > 0)
            {
                Rect position4 = new Rect(x, y2 + 10f, 200f, 20f);
                GUI.Label(position4, new GUIContent("Network observers"), this.m_Styles.labelStyle);
                position4.x += 20f;
                position4.y += position4.height;
                foreach (NetworkConnection observer in this.m_Identity.observers)
                {
                    GUI.Label(position4, observer.address + ":" + (object)observer.connectionId, this.m_Styles.componentName);
                    position4.y += position4.height;
                    y2           = position4.y;
                }
            }
            if (this.m_Identity.clientAuthorityOwner == null)
            {
                return;
            }
            GUI.Label(new Rect(x, y2 + 10f, 400f, 20f), new GUIContent("Client Authority: " + (object)this.m_Identity.clientAuthorityOwner), this.m_Styles.labelStyle);
        }