Ejemplo n.º 1
0
        private static void DrawLineStyle(Rect selectionRect, HierarchyStyle style)
        {
            var setting = style.GetCurrentSettings();

            switch (setting.displayedLine)
            {
            case LineStyle.NONE:
                break;

            case LineStyle.TOP:
                CreateLineSpacer(selectionRect, setting.lineColor);
                break;

            case LineStyle.BOTTOM:
                selectionRect.y += EditorGUIUtility.singleLineHeight * 0.85f;
                CreateLineSpacer(selectionRect, setting.lineColor);
                break;

            case LineStyle.BOTH:
                CreateLineSpacer(selectionRect, setting.lineColor);
                selectionRect.y += EditorGUIUtility.singleLineHeight * 0.85f;
                CreateLineSpacer(selectionRect, setting.lineColor);
                break;
            }
        }
Ejemplo n.º 2
0
        private static void ApplyElementStyle(Rect selectionRect, string name, HierarchyStyle prefix)
        {
            var styleSetting = prefix.GetCurrentSettings();

            name = RemovePrefix(name, prefix.prefix);

            //Setup style
            Color backgroundColor = styleSetting.backgroundColor;
            Color fontCol         = styleSetting.fontColor;

            //Create style to draw
            GUIStyle style = new GUIStyle(settings.GetGUIStyle(prefix.guiStyle))
            {
                alignment = styleSetting.fontAlignment,
                fontSize  = styleSetting.fontSize,
                fontStyle = styleSetting.fontStyle,

                font = styleSetting.font ?? EditorStyles.standardFont,
            };

            style.normal.textColor = fontCol;

            Rect backgroundRect = GetActualHierarchyWidth(selectionRect);
            Rect labelRect      = selectionRect = GetHierarchyStyleSize(selectionRect);

            if (currentInstance.gameObject.transform.parent != null)
            {
                backgroundRect = selectionRect;
                labelRect      = selectionRect;
            }

            //Draw background and label
            EditorGUI.DrawRect(backgroundRect, backgroundColor);

            //Draw twice to take into account full width draw
            //TODO: Consider looking into content offset, draw texture may be a future option
            EditorGUI.LabelField(GetActualHierarchyWidth(selectionRect), "", style);
            EditorGUI.LabelField(labelRect, name.ToUpper(), style);

            //Apply overlay line
            DrawLineStyle(backgroundRect, prefix);
        }