public override void Update()
        {
            foreach (List <KeyValuePair <Component, Behaviour> > stacks in this.stacks.Values)
            {
                stacks.Clear();
            }
            this.stacks.Clear();

            Component[] components = this.GameObject.GetComponents <Component>();
            foreach (Component component in components)
            {
                if (component is Transform)
                {
                    continue;
                }

                Texture   icon      = HierarchyProEditorIcons.GetComponentIcon(component.GetType());
                Behaviour behaviour = component as Behaviour;

                List <KeyValuePair <Component, Behaviour> > stack = null;
                stack = this.stacks.ContainsKey(icon) ? this.stacks[icon] : new List <KeyValuePair <Component, Behaviour> >();
                stack.Add(new KeyValuePair <Component, Behaviour>(component, behaviour));
                this.stacks[icon] = stack;
            }
        }
        public override void Draw(Rect rect)
        {
            int count = this.renderers.Count();

            if (count <= 0)
            {
                this.DrawMeshFilter(rect);

                return;
            }

            Renderer renderer = this.renderers.First();
            Texture  icon     = HierarchyProEditorIcons.GetComponentIcon(renderer.GetType());
            Rect     iconRect = rect.GetCenteredIconRect(icon);

            GUI.DrawTexture(iconRect, icon);

            if (count > 1)
            {
                Rect plusRect = rect.GetCenteredIconRect(HierarchyProEditorIcons.Plus, false);
                GUI.color = new Color(1, 0, 0);
                GUI.DrawTexture(plusRect, HierarchyProEditorIcons.Plus);
                GUI.color = Color.white;
            }
        }
Пример #3
0
        private void DrawCount(Rect rect)
        {
            float iconSize   = 12;
            float labelWidth = (rect.width - (iconSize * 2)) / 2;

            Texture iconTransform = HierarchyProEditorIcons.GetComponentIcon <Transform>();
            Rect    rectTransform = new Rect(rect)
            {
                width = iconSize + labelWidth
            };
            Rect rectIconTransform = new Rect(rectTransform)
            {
                width = iconSize
            };
            Rect rectLabelTransform = new Rect(rectTransform)
            {
                x = rectTransform.x + iconSize, width = labelWidth
            };

            if (this.TransformCount > 0)
            {
                GUI.DrawTexture(rectIconTransform.GetCenteredIconRect(iconTransform, iconSize, iconSize), iconTransform);
                GUI.Label(rectLabelTransform, this.TransformCount.ToString(), HierarchyProEditorStyles.LabelTinyCentered);
            }
            if (GUI.Button(rectTransform, GUIContent.none, GUIStyle.none))
            {
                Selection.objects = this.Transforms.Where(x => (x != null) && (x.gameObject != null)).Select(x => x.gameObject).Cast <Object>().ToArray();
            }

            Texture iconRectTransform = HierarchyProEditorIcons.GetComponentIcon <RectTransform>();
            Rect    rectRectTransform = new Rect(rect)
            {
                width = iconSize + labelWidth, x = rect.x + iconSize + labelWidth
            };
            Rect rectIconRectTransform = new Rect(rectRectTransform)
            {
                width = iconSize
            };
            Rect rectLabelRectTransform = new Rect(rectRectTransform)
            {
                x = rectRectTransform.x + iconSize, width = labelWidth
            };

            if (this.RectTransformCount > 0)
            {
                GUI.DrawTexture(rectIconRectTransform.GetCenteredIconRect(iconRectTransform, iconSize, iconSize), iconRectTransform);
                GUI.Label(rectLabelRectTransform, this.RectTransformCount.ToString(), HierarchyProEditorStyles.LabelTinyCentered);
            }
            if (GUI.Button(rectRectTransform, GUIContent.none, GUIStyle.none))
            {
                Selection.objects = this.RectTransforms.Where(x => (x != null) && (x.gameObject != null)).Select(x => x.gameObject).Cast <Object>().ToArray();
            }
        }
        private void DrawMeshFilter(Rect rect)
        {
            if (this.meshFilter == null)
            {
                return;
            }

            string tooltip = "There are no Renderers, but a MeshFilter is present.";

            if (this.meshFilter.sharedMesh == null)
            {
                tooltip += "\nThe MeshFilter has no Mesh assigned.";
            }

            Texture icon           = HierarchyProEditorIcons.GetComponentIcon <MeshFilter>();
            Rect    rectMeshFilter = rect.GetCenteredIconRect(icon);

            GUI.color = this.meshFilter.sharedMesh != null ? new Color(0.8f, 0.8f, 0.8f, 0.5f) : new Color(0.8f, 0, 0, 0.5f);
            GUI.Label(rectMeshFilter, new GUIContent(icon, tooltip), GUIStyle.none);
            GUI.color = Color.white;
        }
 public static Texture GetComponentIcon <T>()
 {
     return(HierarchyProEditorIcons.GetComponentIcon(typeof(T)));
 }