Example #1
0
        private static void DrawTag(int instanceID, Rect selectionRect)
        {
            if (!data.tag.GetEnabled())
            {
                return;
            }

            string tag = currentGO.tag;

            /* Draw text */
            if (data.tag.enabledText)
            {
                float offset = GUI.skin.label.CalcSize(new GUIContent(tag)).x;

                Rect rect = selectionRect;
                rect.x = selectionRect.xMax - RIGHT_BOUNDARY - offset + (ROW_HEIGHT - 1) - MAX_LAYER_LEN - MAX_INSTID_LEN;

                GUIStyle style = new GUIStyle();
                style.normal.textColor = (tag == "Untagged") ? data.tag.textColorUntagged : data.tag.textColor;

                GUI.Label(rect, tag, style);
            }

            /* Draw item ovelay */
            if (data.tag.enabledItem)
            {
                Color color           = data.tag.GetColorByTag(tag);
                bool  invertDirection = data.tag.invertDirection;
                float startTime       = data.tag.gradientLength;

                HierarchyRenderer.DrawOverlayByDrawMode(
                    selectionRect, currentItem.nestingLevel, color, DrawMode.GRADIENT, startTime, invertDirection);
            }
        }
Example #2
0
        private static void DrawLayer(int instanceID, Rect selectionRect)
        {
            if (!data.layer.GetEnabled())
            {
                return;
            }

            string layer = LayerMask.LayerToName(currentGO.layer);

            /* Draw text */
            if (data.layer.enabledText)
            {
                float offset = GUI.skin.label.CalcSize(new GUIContent(layer)).x;

                Rect rect = selectionRect;
                rect.x = selectionRect.xMax - RIGHT_BOUNDARY - offset + (ROW_HEIGHT - 1) - MAX_INSTID_LEN;

                GUIStyle style = new GUIStyle();
                style.normal.textColor = (layer == "Default") ? data.layer.textColorDefault : data.layer.textColor;

                GUI.Label(rect, layer, style);
            }

            /* Draw item ovelay */
            if (data.layer.enabledItem)
            {
                Color color           = data.layer.GetColorByLayer(layer);
                bool  invertDirection = data.layer.invertDirection;
                float startTime       = data.layer.gradientLength;

                HierarchyRenderer.DrawOverlayByDrawMode(
                    selectionRect, currentItem.nestingLevel, color, DrawMode.GRADIENT, startTime, invertDirection);
            }
        }
Example #3
0
        private static void DrawLog(int instanceID, Rect selectionRect)
        {
            if (!data.log.GetEnabled())
            {
                return;
            }

            Dictionary <string, string> log   = HierarchyLog.LogStorage(LogType.Log);
            Dictionary <string, string> warn  = HierarchyLog.LogStorage(LogType.Warning);
            Dictionary <string, string> error = HierarchyLog.LogStorage(LogType.Error);

            var go = EditorUtility.InstanceIDToObject(instanceID) as GameObject;

            if (go == null || !go.activeSelf)
            {
                return;
            }

            int iconLevel = 0;

            bool drawnLog = HierarchyRenderer.DrawLogIcon(go, selectionRect, log, LogType.Log, iconLevel);

            if (drawnLog)
            {
                ++iconLevel;
            }
            bool drawnWarn = HierarchyRenderer.DrawLogIcon(go, selectionRect, warn, LogType.Warning, iconLevel);

            if (drawnWarn)
            {
                ++iconLevel;
            }
            HierarchyRenderer.DrawLogIcon(go, selectionRect, error, LogType.Error, iconLevel);
        }
Example #4
0
        private static void DrawSeparators(int instanceID, Rect selectionRect)
        {
            // EditorOnly objects are only removed from build if they're not childrens
            if (!data.separator.GetEnabled() || data.separator.color.a <= 0 || !currentItem.isSeparator)
            {
                return;
            }

            // Adds color on top of the label
            if (data.separator.drawFill)
            {
                HierarchyRenderer.DrawFullItem(selectionRect, data.separator.color);
            }
            else
            {
                HierarchyRenderer.DrawSelection(selectionRect, data.separator.color);
            }
        }
Example #5
0
        private static void DrawComponents(int instanceID, Rect selectionRect)
        {
            if (!data.components.GetEnabled())
            {
                return;
            }

            temp_iconsDrawedCount = 0;
            float offsetX_const = 3;
            float offsetX       = RIGHT_BOUNDARY + offsetX_const + MAX_TAG_LEN + MAX_LAYER_LEN + MAX_INSTID_LEN;

            bool omitComp    = data.icons.omitComp;
            bool guessedComp = (currentItem.guessedComponent != null);

            foreach (Component comp in currentItem.components)
            {
                if (omitComp && guessedComp && comp == currentItem.guessedComponent)
                {
                    continue;
                }

                // When component is null, meaning there is broken link
                // so here we accept null value.
                var t     = (comp == null) ? null : comp.GetType();
                var image = HierarchyUtil.TypeTexture(comp, t);

                float offset = offsetX + (ROW_HEIGHT * temp_iconsDrawedCount);
                float x      = selectionRect.xMax - offset;
                Rect  rect   = new Rect(x, selectionRect.yMin, ROW_HEIGHT, ROW_HEIGHT);

                HierarchyRenderer.DrawComponent(t, currentGO, rect, image);

                if (data.components.focus && GUI.Button(rect, "", "Label"))
                {
                    OnClick_Component(instanceID, t);
                }

                ++temp_iconsDrawedCount;
            }
        }
Example #6
0
        private static void DrawAlternatingBG(int instanceID, Rect selectionRect)
        {
            if (!data.alterRowShading.GetEnabled())
            {
                return;
            }

            var isOdd = Mathf.FloorToInt(((selectionRect.y - 4) / ROW_HEIGHT) % 2) != 0;

            if (isOdd)
            {
                return;
            }

            if (data.alterRowShading.drawFill)
            {
                HierarchyRenderer.DrawFullItem(selectionRect, data.alterRowShading.color);
            }
            else
            {
                HierarchyRenderer.DrawSelection(selectionRect, data.alterRowShading.color);
            }
        }
Example #7
0
        private static void DrawTree(int instanceID, Rect selectionRect)
        {
            if (!data.tree.GetEnabled() || currentItem.nestingLevel < 0)
            {
                return;
            }

            // prevents drawing when the hierarchy search mode is enabled
            if (selectionRect.x >= 60)
            {
                // Group
                if (data.tree.colorizedItem && currentItem.topParentHasChild && !currentItem.isSeparator)
                {
                    HierarchyRenderer.DrawNestGroupOverlay(selectionRect, currentItem.nestingLevel);
                }

                HierarchyRenderer.DrawDottedLine(selectionRect, 0, 0);

                if (currentItem.nestingLevel == 0 && !currentItem.hasChilds)
                {
                    HierarchyRenderer.DrawHalfVerticalLineFrom(selectionRect, true, 0, data.tree.baseLevelColor);
                    if (!currentItem.isLastElement)
                    {
                        HierarchyRenderer.DrawHalfVerticalLineFrom(selectionRect, false, 0, data.tree.baseLevelColor);
                    }
                }
                else
                {
                    // Draws a vertical line for each previous nesting level
                    for (int level = 0; level <= currentItem.nestingLevel; ++level)
                    {
                        bool currentLevel = (currentItem.nestingLevel == level);

                        if (currentLevel && currentItem.hasChilds)
                        {
                            continue;
                        }

                        if (currentLevel && !currentItem.hasChilds)
                        {
                            HierarchyRenderer.DrawHalfVerticalLineFrom(selectionRect, true, level);
                            if (!currentItem.isLastElement)
                            {
                                HierarchyRenderer.DrawHalfVerticalLineFrom(selectionRect, false, level);
                            }
                        }
                        else
                        {
                            HierarchyRenderer.DrawDottedLine(selectionRect, level);
                        }
                    }
                }

                if (!currentItem.hasChilds)
                {
                    HierarchyRenderer.DrawHorizontalLineFrom(selectionRect, currentItem.nestingLevel, currentItem.hasChilds);
                }
            }

            // draws a super small divider between different groups
            if (currentItem.nestingLevel == 0 && data.tree.dividerHeight > 0)
            {
                Rect boldGroupRect = new Rect(
                    32, selectionRect.y - data.tree.dividerHeight / 2f,
                    selectionRect.width + (selectionRect.x - 32),
                    data.tree.dividerHeight);
                EditorGUI.DrawRect(boldGroupRect, data.tree.dividerColor * .3f);
            }
        }