예제 #1
0
            public Styles()
            {
                var text = new RectangleTexture();

                text.Resolution  = 16;
                text.FillColor   = new Color(0.24f, 0.49f, 0.91f, 1.00f);
                text.BorderColor = new Color(0.24f, 0.49f, 0.91f, 1.00f);
                Texture2D texture = text.Generate();



                this.header.font = EditorStyles.boldLabel.font;

                this.componentButton.alignment     = TextAnchor.MiddleLeft;
                this.componentButton.padding.left -= 15;
                this.componentButton.fixedHeight   = 20f;

                this.componentButton.hover.background   = texture;
                this.componentButton.hover.textColor    = Color.white;
                this.componentButton.focused.background = texture;
                this.componentButton.focused.textColor  = Color.white;
                this.componentButton.active.background  = texture;
                this.componentButton.active.textColor   = Color.white;

                this.groupButton = new GUIStyle(this.componentButton);
                this.groupButton.padding.left  += 17;
                this.previewText.padding.left  += 3;
                this.previewText.padding.right += 3;
                ++this.previewHeader.padding.left;
                this.previewHeader.padding.right  += 3;
                this.previewHeader.padding.top    += 3;
                this.previewHeader.padding.bottom += 2;
            }
예제 #2
0
        public static void DrawInspectorTitle(string title, string description = "")
        {
            GUIStyle titleboxStyle = new GUIStyle(GUI.skin.box);

            titleboxStyle.padding = new RectOffset(3, 3, 3, 3);

            var text = new RectangleTexture();

            text.Resolution  = 2;
            text.FillColor   = _backgroundColor;
            text.BorderColor = _backgroundColor;
            Texture2D texture = text.Generate();

            titleboxStyle.normal.background = texture;



            EditorGUILayout.BeginHorizontal(titleboxStyle);

            if (_inspectorTitleSize == Vector2.zero)
            {
                float w = DialogueSystemIcon.normal.background.width;
                float h = DialogueSystemIcon.normal.background.height;

                _inspectorTitleSize.y = 30f;
                _inspectorTitleSize.x = (_inspectorTitleSize.y / h) * w;
            }

            EditorGUILayout.LabelField("", DialogueSystemIcon, GUILayout.Width(_inspectorTitleSize.x), GUILayout.Height(_inspectorTitleSize.y));

            GUILayout.Space(5);

            GUIContent label = new GUIContent(title);
            var        size  = TitleStyle.CalcSize(label);

            EditorGUILayout.LabelField(label, TitleStyle, GUILayout.Width(size.x));

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
            if (description != "")
            {
                Color lGUIColor = GUI.color;
                GUI.color = _backgroundColor.gamma;
                EditorGUILayout.HelpBox(description, MessageType.None);
                GUI.color = lGUIColor;
            }


            EditorGUILayout.Space();
        }
예제 #3
0
        void OnGUI()
        {
            if (_styles == null)
            {
                _styles = new Styles();
            }
            if (_emptyIcon == null)
            {
                var text = new RectangleTexture();
                text.FillColor   = new Color(0, 0, 0, 0);
                text.BorderColor = text.FillColor;
                text.Resolution  = 16;
                _emptyIcon       = text.Generate();
            }


            // Background border
            GUI.Label(new Rect(0.0f, 0.0f, this.position.width, this.position.height), GUIContent.none, _styles.background);

            // SEARCH FIELD
            GUILayout.Space(7);
            GUILayout.BeginHorizontal();
            _searchString = GUILayout.TextField(_searchString, GUI.skin.FindStyle("SearchTextField"));
            var buttonStyle = _searchString == string.Empty ? GUI.skin.FindStyle("SearchCancelButtonEmpty") : GUI.skin.FindStyle("SearchCancelButton");

            if (GUILayout.Button(string.Empty, buttonStyle))
            {
                // Remove focus if cleared
                _searchString = string.Empty;
                GUI.FocusControl(null);
            }
            GUILayout.EndHorizontal();

            Rect        panelRect = new Rect(1, 30, position.width - 2, position.height - 30);
            string      t         = _group.Count == 0 ? title : _group[_group.Count - 1].Name;
            List <Menu> list      = (_group.Count == 0) ? menu : _group[_group.Count - 1].Items;

            // MENU
            GUILayout.BeginArea(panelRect);
            panelRect = GUILayoutUtility.GetRect(10f, 25f);

            // TITLE BAR
            if (GUI.Button(panelRect, (_searchString != string.Empty) ? "Search" : t, _styles.header))
            {
                HierarchyUp();
            }
            if (_group.Count > 0)
            {
                GUI.Label(new Rect(panelRect.x + 6.5f, panelRect.y + 6.5f, 13, 13), "", _styles.leftArrow);
            }

            // LIST
            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition);

            // Apply search
            if (_searchString != string.Empty)
            {
                var         searchString = _searchString.ToLower();
                List <Menu> visible      = new List <Menu>();
                foreach (var item in menu)
                {
                    FilterMenuItem(item, searchString, ref visible);
                }

                list = visible;
            }

            // Draw items
            int lastPriority = -1;

            foreach (var item in list)
            {
                if (lastPriority != item.Priority)
                {
                    if (lastPriority > 0)
                    {
                        GUILayout.Box("", (GUIStyle)"AppToolbar", GUILayout.Width(position.width - 5), GUILayout.Height(2));
                    }
                    lastPriority = item.Priority;
                }

                MenuGroup g = item as MenuGroup;

                var buttonRect = GUILayoutUtility.GetRect(16f, 20f, GUILayout.ExpandWidth(true));

                GUIContent c = new GUIContent(item.Name, (item.Icon != null) ? item.Icon : _emptyIcon);
                if (GUI.Button(buttonRect, c, _styles.componentButton))
                {
                    if (g != null)
                    {
                        HierarchyDown(g);
                    }
                    else
                    {
                        OnItemSelected((MenuItem)item);
                        Close();
                    }
                }
                if (g != null)
                {
                    GUI.Label(new Rect(buttonRect.x + buttonRect.width - 26,
                                       buttonRect.y + 4f,
                                       13f, 13f),
                              "", (GUIStyle)"AC RightArrow");
                }
            }



            GUILayout.EndScrollView();
            GUILayout.EndArea();

            Repaint();
        }