Example #1
0
        public static int TabBar(int active, string[] tabs)
        {
            var tabStyle      = GetTabStyle();
            var inactiveColor = new Color(0.4f, 0.4f, 0.4f);
            var selectedColor = new Color(0.7725491f, 0.764706f, 0.7686275f);

            using (new GUILayout.HorizontalScope())
            {
                for (var i = 0; i < tabs.Length; i++)
                {
                    using (ColorScope.BackgroundColor(i == active ? Color.white : inactiveColor))
                    {
                        if (GUILayout.Button(tabs[i], tabStyle))
                        {
                            active = i;
                        }
                    }
                }
            }

            var lineRect = GUILayoutUtility.GetLastRect();

            lineRect.y     += lineRect.height - 2;
            lineRect.height = 2;

            Box(lineRect, selectedColor);

            return(active);
        }
Example #2
0
        public static void Box(Rect box, Color color)
        {
            var style = GetBoxStyle();

            using (ColorScope.Color(color))
                GUI.Box(box, GUIContent.none, style);
        }
Example #3
0
        public static void Outline(Rect box, Color color, float thickness)
        {
            var style      = GetBoxStyle();
            var topRect    = new Rect(box.x, box.y, box.width, thickness);
            var bottomRect = new Rect(box.x, box.y + box.height - thickness, box.width, thickness);
            var leftRect   = new Rect(box.x, box.y + thickness, thickness, box.height - thickness - thickness);
            var rightRect  = new Rect(box.x + box.width - thickness, box.y + thickness, thickness, box.height - thickness - thickness);

            using (ColorScope.BackgroundColor(color))
            {
                GUI.Box(topRect, GUIContent.none, style);
                GUI.Box(bottomRect, GUIContent.none, style);
                GUI.Box(leftRect, GUIContent.none, style);
                GUI.Box(rightRect, GUIContent.none, style);
            }
        }