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;
            }
        }
        public static void Load()
        {
            HierarchyProEditorIcons.select  = HierarchyProEditorIcons.LoadCustomIcon("Select");
            HierarchyProEditorIcons.note    = HierarchyProEditorIcons.LoadCustomIcon("Note");
            HierarchyProEditorIcons.delete  = HierarchyProEditorIcons.LoadCustomIcon("Delete");
            HierarchyProEditorIcons.info    = HierarchyProEditorIcons.LoadCustomIcon("Info");
            HierarchyProEditorIcons.warning = HierarchyProEditorIcons.LoadCustomIcon("Warning");
            HierarchyProEditorIcons.error   = HierarchyProEditorIcons.LoadCustomIcon("Error");

            HierarchyProEditorIcons.cog          = HierarchyProEditorIcons.LoadBuiltIn("d_SettingsIcon");
            HierarchyProEditorIcons.prefab       = HierarchyProEditorIcons.LoadBuiltIn("PrefabNormal Icon");
            HierarchyProEditorIcons.scriptCS     = HierarchyProEditorIcons.LoadBuiltIn("cs Script Icon");
            HierarchyProEditorIcons.folderClosed = HierarchyProEditorIcons.LoadBuiltIn("Folder Icon");
            HierarchyProEditorIcons.folderOpen   = HierarchyProEditorIcons.LoadBuiltIn("FolderEmpty Icon");
            HierarchyProEditorIcons.group        = HierarchyProEditorIcons.LoadBuiltIn("d_VerticalLayoutGroup Icon");
            HierarchyProEditorIcons.favorite     = HierarchyProEditorIcons.LoadBuiltIn("Favorite Icon");

            HierarchyProEditorIcons.checkmarkOff     = IconPair.LoadBuiltIn("toggle");
            HierarchyProEditorIcons.checkmarkPartial = IconPair.LoadBuiltIn("toggle mixed");
            HierarchyProEditorIcons.checkmarkOn      = IconPair.LoadBuiltIn("toggle on");
            HierarchyProEditorIcons.lockedOff        = IconPair.LoadBuiltIn("IN LockButton");
            HierarchyProEditorIcons.lockedOn         = IconPair.LoadBuiltIn("IN LockButton on");
            HierarchyProEditorIcons.pin               = IconPair.LoadBuiltIn("eventpin on");
            HierarchyProEditorIcons.plus              = IconPair.LoadBuiltIn("ShurikenPlus");
            HierarchyProEditorIcons.minus             = IconPair.LoadBuiltIn("ShurikenMinus");
            HierarchyProEditorIcons.helpbox           = IconPair.LoadBuiltIn("PingBox");
            HierarchyProEditorIcons.toolbarHorizontal = IconPair.LoadBuiltIn("Toolbar");
            HierarchyProEditorIcons.dropHighlight     = IconPair.LoadBuiltIn("PR DropHere");

            HierarchyProEditorIcons.labelNumber = HierarchyProEditorIcons.LoadCustomIcon("NumberPanel");
        }
        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;
            }
        }
示例#4
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;
        }
        private static void Load()
        {
            HierarchyProPreferences.Load();

            HierarchyProEditorCache.Initialize();
            HierarchyProEditorReflection.Load();
            HierarchyProEditorIcons.Load();
            HierarchyProEditorColors.Load();
            HierarchyProEditorStyles.Load();

            HierarchyProGroupLibrary.FindInstance();

            EditorApplication.update -= HierarchyProEditorLoader.Update;
            EditorApplication.hierarchyWindowChanged   -= HierarchyProEditorLoader.WindowChanged;
            EditorApplication.hierarchyWindowItemOnGUI -= HierarchyProEditorLoader.ItemOnGUI;
            Undo.undoRedoPerformed -= HierarchyProEditorLoader.UndoRedoPerformed;

            EditorApplication.update += HierarchyProEditorLoader.Update;
            EditorApplication.hierarchyWindowChanged   += HierarchyProEditorLoader.WindowChanged;
            EditorApplication.hierarchyWindowItemOnGUI += HierarchyProEditorLoader.ItemOnGUI;
            Undo.undoRedoPerformed += HierarchyProEditorLoader.UndoRedoPerformed;
        }
 public static Texture GetComponentIcon <T>()
 {
     return(HierarchyProEditorIcons.GetComponentIcon(typeof(T)));
 }