Ejemplo n.º 1
0
        private void OnGUI()
        {
            EditorGUILayout.HelpBox("1-9 - Select scenes; R - Refresh scenes; X - Close", MessageType.Info);

            if (CheckInputs())
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            search = searchField.OnGUI(search);
            if (EditorGUI.EndChangeCheck())
            {
                Research();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Results:", EditorStyles.boldLabel);
            ignoreShortcuts = GUILayout.Toggle(ignoreShortcuts, "Ignore", "Button");
            GUILayout.EndHorizontal();

            for (int i = 0; i < searchScenes.Count; i++)
            {
                GUILayout.Label((i < 9 ? (i + 1).ToString() : "-") + "    " + searchScenes[i].name);
            }
        }
Ejemplo n.º 2
0
        void TopToolbar(Rect rect)
        {
            GUILayout.BeginArea(rect);
            GUILayout.BeginHorizontal();

            var style = new GUIStyle();

            style.fontSize = 14;

            GUILayout.Label("Quest Database", style);

            if (GUILayout.Button("New"))
            {
                quests = _connection.Table <QuestEntry>();
            }
            if (GUILayout.Button("Refresh"))
            {
                if (_connection == null)
                {
                    Connect();
                }
                quests        = _connection.Table <QuestEntry>();
                m_Initialized = false;
                InitIfNeeded();
                Repaint();
            }

            treeView.searchString = m_SearchField.OnGUI(treeView.searchString);

            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
Ejemplo n.º 3
0
    private void DrawTopBar()
    {
        var newSearchFilter = searchField.OnGUI(searchFilter);

        GUILayout.Space(4);

        // If the requested search filter has changed.
        if (newSearchFilter != searchFilter)
        {
            searchFilter = newSearchFilter;
            // Trigger UpdateSearch to calculate new search results.
            UpdateSearch();
        }

        // Allow the user to toggle between editor and PlayerPrefs.
        var oldIndex = showEditorPrefs ? 1 : 0;
        var newIndex = GUILayout.Toolbar(oldIndex, new string[] { "PlayerPrefs", "EditorPrefs" });

        // Has the toggle changed?
        if (newIndex != oldIndex)
        {
            // Reset.
            lastDeserialization = null;
            showEditorPrefs     = (newIndex == 1);
        }
    }
Ejemplo n.º 4
0
    private void DrawTopBar()
    {
#if UNITY_5_6_OR_NEWER
        string newSearchFilter = searchField.OnGUI(searchFilter);
        GUILayout.Space(4);
#else
        EditorGUILayout.BeginHorizontal();
        // Heading
        GUILayout.Label("Search", GUILayout.MaxWidth(50));
        // Actual search box
        string newSearchFilter = EditorGUILayout.TextField(searchFilter);

        EditorGUILayout.EndHorizontal();
#endif

        // If the requested search filter has changed
        if (newSearchFilter != searchFilter)
        {
            searchFilter = newSearchFilter;
            // Trigger UpdateSearch to calculate new search results
            UpdateSearch();
        }

        // Allow the user to toggle between editor and PlayerPrefs
        int oldIndex = showEditorPrefs ? 1 : 0;
        int newIndex = GUILayout.Toolbar(oldIndex, new string[] { "PlayerPrefs", "EditorPrefs" });

        // Has the toggle changed?
        if (newIndex != oldIndex)
        {
            // Reset
            lastDeserialization = null;
            showEditorPrefs     = (newIndex == 1);
        }
    }
Ejemplo n.º 5
0
        public override void OnGUI(Rect pos)
        {
            styles = styles ?? new Styles();
            if (CheckDragAndDrop(parent.position))
            {
                CheckDragPerform(pos);
            }
            else
            {
                GUI.Box(pos, string.Empty, GUI.skin.box);
                if (!rootItem.hasChildren)
                {
                    GUI.Label(pos, "拖动文件夹至此添加配置", styles.dragDropLabelStyle);
                }
                else
                {
                    var searchFieldRect = new Rect(pos.x + 10, pos.y + 10, pos.width - 20, 20);
                    searchString = searchField.OnGUI(searchFieldRect, searchString);
                    base.OnGUI(new Rect(pos.x + 1, searchFieldRect.yMax + 3, pos.width - 2, pos.height - searchFieldRect.height - 20 - 3));
                    if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && pos.Contains(Event.current.mousePosition))
                    {
                        SetSelection(new int[0], TreeViewSelectionOptions.FireSelectionChanged);
                    }
                }
            }

            if (dirty)
            {
                dirty = false;
                Reload();
            }
        }
Ejemplo n.º 6
0
            public override void OnGUI(Rect rect)
            {
                searchText = searchField.OnGUI(searchText);

                scrollPosition = EGL.BeginScrollView(scrollPosition);

                foreach (var type in behaviourTypes)
                {
                    if (type.ToLower().Contains(searchText.ToLower()))
                    {
                        EGL.BeginHorizontal();
                        EGL.LabelField(type, GL.Width(140));
                        if (GL.Button("Add", GL.Width(40)))
                        {
                            var instance = (StateBehaviour)ScriptableObject.CreateInstance(type);
                            instance.name      = type;
                            instance.hideFlags = HideFlags.HideInHierarchy;
                            list.Add(instance);

                            AssetDatabase.AddObjectToAsset(instance, profile);
                            AssetDatabase.SaveAssets();

                            editorWindow.Close();
                        }
                        EGL.EndHorizontal();
                    }
                }

                EGL.EndScrollView();
            }
        void DoSearchField(Rect rect, bool asToolbar)
        {
            if (searchField == null)
            {
                searchField = new SearchField();
                searchField.SetFocus();
                searchField.downOrUpArrowKeyPressed += OnDownOrUpArrowKeyPressed;
            }

            var result = asToolbar
                ? searchField.OnToolbarGUI(rect, searchString)
                : searchField.OnGUI(rect, searchString);

            if (result != searchString && onInputChanged != null)
            {
                onInputChanged(result);
                selectedIndex = 0;
                showResults   = true;
            }

            searchString = result;

            if (HasSearchbarFocused())
            {
                RepaintFocusedWindow();
            }
        }
        public override void OnInspectorGUI()
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label("Clipboard(tsv):");

                if (GUILayout.Button("Copy", EditorStyles.miniButton))
                {
                    var csv = ToTSV();
                    GUIUtility.systemCopyBuffer = csv;
                }

                if (GUILayout.Button("Paste", EditorStyles.miniButton))
                {
                    var csv = GUIUtility.systemCopyBuffer;
                    ReadFromTSV(csv);
                }
            }

            treeView.searchString = searchField.OnGUI(treeView.searchString);

            var rect = EditorGUILayout.GetControlRect(false, 200);

            treeView.OnGUI(rect);

            GUILayout.Space(10);

            SelectedMessageView();
        }
Ejemplo n.º 9
0
        public void Draw()
        {
            GUILayout.Space(3);
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(5);
                using (new GUILayout.VerticalScope())
                {
                    EditorGUI.BeginChangeCheck();
                    var searchString =
                        searchField.OnGUI(
                            GUILayoutUtility.GetRect(0, 0, 20, 20, GUILayout.ExpandWidth(true),
                                                     GUILayout.ExpandHeight(false)), UserSettings.References.sceneTabSearchString);
                    if (EditorGUI.EndChangeCheck())
                    {
                        UserSettings.References.sceneTabSearchString = searchString;
                        treeView.SetSearchString(searchString);
                        treeView.Reload();
                    }

                    GUILayout.Space(3);

                    using (new GUILayout.VerticalScope())
                    {
                        treeView.OnGUI(GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandWidth(true),
                                                                GUILayout.ExpandHeight(true)));
                        GUILayout.Space(2f);
                    }
                }

                GUILayout.Space(5);
            }
        }
Ejemplo n.º 10
0
 private void SearchBar(Rect rect)
 {
     if (treeView != null && searchField != null)
     {
         treeView.searchString = searchField.OnGUI(rect, treeView.searchString);
     }
 }
Ejemplo n.º 11
0
 void doSearchBar(Rect rect)
 {
     if (m_TreeView != null)
     {
         m_TreeView.searchString = m_SearchField.OnGUI(rect, m_TreeView.searchString);
     }
 }
Ejemplo n.º 12
0
        public override void OnGUI(Rect rect)
        {
            const int border       = 4;
            const int topPadding   = 12;
            const int searchHeight = 20;
            const int buttonHeight = 16;
            const int remainTop    = topPadding + searchHeight + buttonHeight + border + border;

            float selectAllWidth   = EditorStyles.miniButton.CalcSize(Styles.SelectAllButtonLabel).x;
            float deselectAllWidth = EditorStyles.miniButton.CalcSize(Styles.DeselectAllButtonLabel).x;

            Rect searchRect      = new Rect(border, topPadding, rect.width - border * 2, searchHeight);
            Rect selectAllRect   = new Rect(border, topPadding + searchHeight + border, selectAllWidth, buttonHeight);
            Rect deselectAllRect = new Rect(border + selectAllWidth + border, topPadding + searchHeight + border, deselectAllWidth, buttonHeight);
            Rect remainingRect   = new Rect(border, remainTop, rect.width - border * 2, rect.height - remainTop - border);

            m_TreeView.searchString = m_SearchField.OnGUI(searchRect, m_TreeView.searchString);

            if (GUI.Button(selectAllRect, Styles.SelectAllButtonLabel, EditorStyles.miniButton))
            {
                m_TreeView.SelectAll();
            }

            if (GUI.Button(deselectAllRect, Styles.DeselectAllButtonLabel, EditorStyles.miniButton))
            {
                m_TreeView.DeselectAll();
            }

            m_TreeView.OnGUI(remainingRect);
        }
Ejemplo n.º 13
0
        private void OnGUI()
        {
            using (new HorizontalScope(EditorStyles.toolbar))
            {
                isDarkSkinSelected = !GUILayout.Toggle(!isDarkSkinSelected, "Light", EditorStyles.toolbarButton);
                isDarkSkinSelected = GUILayout.Toggle(isDarkSkinSelected, "Dark", EditorStyles.toolbarButton);
            }

            searchString = _searchField.OnGUI(searchString);

            var so   = new SerializedObject(this);
            var prop = so.FindProperty(isDarkSkinSelected ? nameof(dark) : nameof(light));

            EditorGUIUtility.labelWidth = 270;
            using (var scrollScope = new ScrollViewScope(scrollPos))
            {
                foreach (var property in GetPropChildren(prop))
                {
                    var label = GetDisplayNameOfPropertyBackingField(property.displayName);
                    if (!string.IsNullOrWhiteSpace(searchString) &&
                        !label.ToUpperInvariant().Contains(searchString.ToUpperInvariant()))
                    {
                        continue;
                    }
                    PropertyField(property, new GUIContent(label));
                }

                scrollPos = scrollScope.scrollPosition;
            }
        }
Ejemplo n.º 14
0
        private void DoSearchField(Rect rect, bool asToolbar)
        {
            if (searchField == null)
            {
                searchField = new SearchField();
                searchField.autoSetFocusOnFindCommand = false;
                searchField.downOrUpArrowKeyPressed  += OnDownOrUpArrowKeyPressed;
            }

            var result = asToolbar
                ? searchField.OnToolbarGUI(rect, searchString)
                : searchField.OnGUI(rect, searchString);

            if (result != searchString && onInputChanged != null)
            {
                onInputChanged(result);
                selectedIndex = -1;
                showResults   = true;
            }

            searchString = result;

            if (!inPropertyDrawer && HasSearchbarFocused())
            {
                RepaintFocusedWindow();
            }
        }
Ejemplo n.º 15
0
        private void AssetListGUI()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            searchMode = (SearchMode)EditorGUILayout.EnumPopup(searchMode, GUILayout.Width(80));
            Rect rect = GUILayoutUtility.GetRect(position.width - 130, 25);

            rect.height = 20;
            rect.y     += 3;

            searchText = searchField.OnGUI(rect, searchText);
            if (searchField.HasFocus() && Event.current.rawType == EventType.KeyUp && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter))
            {
                projecListTreeView.Filtter(searchText, searchMode);
                searchField.SetFocus();
            }

            if (GUILayout.Button(createAssetIcon, GUILayout.Width(20), GUILayout.Height(17)))
            {
                string path = EditorUtility.SaveFilePanelInProject("创建", "New TimelineLite", "asset", "");
                if (!string.IsNullOrEmpty(path))
                {
                    AssetDatabase.CreateAsset(ScriptableObject.CreateInstance(TimelineLiteAssetType), path);
                    AssetDatabase.Refresh();
                }
            }
            GUILayout.Space(10);
            GUILayout.EndHorizontal();

            rect.x      = 10;
            rect.y     += 20;
            rect.width  = position.width - 20;
            rect.height = position.height - rect.y - 5;
            projecListTreeView.OnGUI(rect);
        }
Ejemplo n.º 16
0
        public static string SearchFieldWithPopupMenu(Rect position, string label, SearchField searchField, string searchCondition, System.Action <GenericMenu> func, string labelHtmlString = "", string tooltip = "")
        {
            Color labelColor;
            Rect  labelPosition;

            var searchPosition = PrefixLabel(position, out labelPosition);
            var color          = GUI.color;

            if (ColorUtility.TryParseHtmlString(labelHtmlString, out labelColor))
            {
                GUI.color = labelColor;
            }
            EditorGUI.LabelField(labelPosition, new GUIContent(label, tooltip));
            GUI.color = color;

            searchCondition = searchField.OnGUI(searchPosition, searchCondition);

            if (!string.IsNullOrEmpty(searchCondition))
            {
                var popupMenu = new GenericMenu();

                func(popupMenu);

                if ((Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return) && popupMenu.GetItemCount() > 0)
                {
                    popupMenu.DropDown(position);
                }
            }
            return(searchCondition);
        }
Ejemplo n.º 17
0
        private void OnGUI()
        {
            DrawFileSelect();

            if (psd != null)
            {
                TryInitTreeView();
                var width      = position.width * menuRetio;
                var searchRect = new Rect(0, EditorGUIUtility.singleLineHeight, width, EditorGUIUtility.singleLineHeight);
                m_TreeView.searchString = m_SearchField.OnGUI(searchRect, m_TreeView.searchString);
                var treeViewRect = new Rect(0, EditorGUIUtility.singleLineHeight, width, position.height - 2 * EditorGUIUtility.singleLineHeight);

                GUI.Box(treeViewRect, "");
                m_TreeView.OnGUI(treeViewRect);

                var toolRect = new Rect(0, position.height - EditorGUIUtility.singleLineHeight, width, EditorGUIUtility.singleLineHeight);
                BottomToolBar(toolRect);

                var rightWidth = position.width * (1 - menuRetio);
                var configRect = new Rect(width, EditorGUIUtility.singleLineHeight, rightWidth, EditorGUIUtility.singleLineHeight);
                DrawConfigs(configRect);

                var viewRect = new Rect(width, 2 * EditorGUIUtility.singleLineHeight, rightWidth, position.height - 3 * EditorGUIUtility.singleLineHeight);
                DrawTexturePreview(viewRect);

                var previewToolRect = new Rect(width, position.height - EditorGUIUtility.singleLineHeight, rightWidth, EditorGUIUtility.singleLineHeight);
                PreviewToolBars(previewToolRect);
            }
            else
            {
                EditorGUILayout.HelpBox("请先选择正确的PDF文件路径", MessageType.Warning);
            }
        }
Ejemplo n.º 18
0
        private void RenderVariablesToolbar()
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.BeginHorizontal();

            string previousSearch = currentSearchString;

            if (ShowSearchBar)
            {
                currentSearchString = searchBar.OnGUI(currentSearchString);
            }

            if (previousSearch != currentSearchString)
            {
                RefreshFilteredIndex();
            }

            if (!DisplayAddMenu && ShowAddButton)
            {
                if (GUILayout.Button("+"))
                {
                    DisplayAddMenu = true;
                }
            }

            EditorGUILayout.EndHorizontal();

            if (DisplayAddMenu)
            {
                RenderNewVariableSection();
            }

            EditorGUILayout.EndVertical();
        }
        /// <summary>
        /// Render SearchSuggest
        /// </summary>
        /// <returns>true if EditorWindow should Repaint, otherwise false</returns>
        public bool OnSuggestGUI(Rect rect, string label)
        {
            if (searchField == null)
            {
                searchField = new SearchField {
                    autoSetFocusOnFindCommand = true
                }
            }
            ;

            var labelRect = new Rect(rect.position,
                                     new Vector2(labelWidth, singleLineHeight + 4));

            var offset    = Vector2.right * labelWidth;
            var fieldRect = new Rect(rect.position + offset, rect.size - offset);

            GUI.Label(labelRect, label);

            EditorGUI.BeginChangeCheck();
            searchString = searchField.OnGUI(fieldRect, searchString);
            if (EditorGUI.EndChangeCheck())
            {
                searchEnumeration = Evaluate(searchString);
                if (popupWindow)
                {
                    popupWindow.Repaint();
                }
                return(true);
            }
            ShowOptions(fieldRect, searchEnumeration);

            return(false);
        }
Ejemplo n.º 20
0
 private void LanGroupKeysView()
 {
     this.DrawHorizontal(() => {
         this.Foldout(ref keyFoldon, string.Format("Keys  Count: {0}", window._keys.Count), true);
         this.Label("");
         searchField.OnGUI(GUILayoutUtility.GetLastRect());
     }, Styles.Fold);
     if (keyFoldon)
     {
         this.DrawScrollView(() => {
             window._keys.ForEach((index, key) => {
                 if (key.ToLower().Contains(keySearchStr.ToLower()))
                 {
                     this.BeginHorizontal(Styles.BG)
                     .SelectableLabel(key, GUILayout.Height(20))
                     .Label(window.IsKeyInUse(key) ? GUIContent.none : Contents.Warnning, GUILayout.Width(smallBtnSize))
                     .Button(() => {
                         if (EditorUtility.DisplayDialog("Make sure", "You Will Delete All Pairs with this key", "ok", "no"))
                         {
                             window.DeleteLanKey(key);
                         }
                     }, string.Empty, Styles.CloseBtn, GUILayout.Width(smallBtnSize), GUILayout.Height(smallBtnSize))
                     .EndHorizontal();
                 }
             });
         }, ref scroll);
     }
 }
Ejemplo n.º 21
0
        private void OnGUI()
        {
            Rect rect = new Rect(0, 0, position.width, position.height);

            rect.SplitHorizontal(lineX, out Rect left, out Rect right);

            //绘制分割线
            lineX = splitLine.Vertical(lineX, rect.y, 80, 200, rect.height);

            //left
            {
                left.SplitVertical(22, out Rect top, out Rect bottom);

                // Top
                {
                    GUI.Label(top, GUIContent.none, EditorStyles.toolbar);
                    treeSearch = searchField.OnGUI(top.GetPadding(2, 2, 2, 0), treeSearch);
                }

                //bottom
                {
                    treeView.OnGUI(bottom.GetPadding(2, 2, 2, 0));

                    // Clear select
                    {
                        var e = Event.current;
                        if (e.type == EventType.MouseDown && e.button == 0 && bottom.Contains(e.mousePosition))
                        {
                            treeViewState.selectedIDs = new List <int>(0);
                            e.Use();
                        }
                        //右键 todo
                        else if (e.type == EventType.MouseDown && e.button == 1 && bottom.Contains(e.mousePosition))
                        {
                            // 打开脚本文件
                            //e.Use();
                        }
                    }
                }
            }

            //right
            {
                if (providerData.CurrentProvider != null)
                {
                    var rightContent = right.GetPadding(4, 0, 4, 0);

                    GUI.BeginGroup(rightContent);
                    {
                        EditorGUILayout.BeginVertical(GUILayout.Width(rightContent.width), GUILayout.Height(rightContent.height));
                        {
                            providerData.CurrentProvider.OnDraw();
                        }
                        EditorGUILayout.EndVertical();
                    }
                    GUI.EndGroup();
                }
            }
        }
Ejemplo n.º 22
0
 public static string OnGUI(this SearchField self, string label, string content)
 {
     EGL.BeginHorizontal();
     EGL.PrefixLabel(label);
     content = self.OnGUI(content);
     EGL.EndHorizontal();
     return(content);
 }
Ejemplo n.º 23
0
 private void OnGUI()
 {
     if (_searchField == null)
     {
         _searchField = new SearchField();
     }
     _searchField.OnGUI(new Rect(0, 0, 100, 25), "");
 }
Ejemplo n.º 24
0
        void OnGUI()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
            {
                return;
            }

            if (GUILayout.Button("Clean Unused Assets"))
            {
                EditorUtility.UnloadUnusedAssetsImmediate();
                OnHierarchyChange();
            }

            Rect searchRect = GUILayoutUtility.GetRect(new GUIContent(""), EditorStyles.textField, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));

            EditorGUI.BeginChangeCheck();
            m_SearchPattern = m_SearchField.OnGUI(searchRect, m_SearchPattern);
            if (EditorGUI.EndChangeCheck())
            {
                OnHierarchyChange();
            }

            m_Scroll = GUILayout.BeginScrollView(m_Scroll);

            GUILayout.Label("All: " + m_Count, EditorStyles.boldLabel);

            GUILayout.Space(12);

            GUI.skin.label.richText = true;

            bool doReload = false;

            EditorGUI.BeginChangeCheck();

            for (int i = 0; i < m_Objects.Length; i++)
            {
                m_Objects[i].expanded = EditorGUILayout.Foldout(m_Objects[i].expanded, m_Objects[i].name + m_Objects[i].objects.Length);

                if (m_Objects[i].expanded)
                {
                    DrawObjectArray(m_Objects[i].objects);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                doReload = true;
            }

            GUILayout.EndScrollView();

            if (doReload)
            {
                OnHierarchyChange();
                EditorGUIUtility.ExitGUI();
            }
        }
Ejemplo n.º 25
0
 void OnGUISearchBar(Rect rect)
 {
     EditorGUI.BeginChangeCheck();
     searchString = m_searchField.OnGUI(rect, searchString);
     if (EditorGUI.EndChangeCheck())
     {
         m_TreeView.Search(searchString);
     }
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Draws the Categories editor.
        /// </summary>
        private void DrawCategories()
        {
            var categories = m_ItemCollection.Categories;

            if (categories == null)
            {
                // At least one category needs to exist.
                var category = ScriptableObject.CreateInstance <Category>();
                category.ID   = Category.GenerateID();
                category.name = "Items";
                categories    = m_ItemCollection.Categories = new Category[] { category };

                AssetDatabase.AddObjectToAsset(category, AssetDatabase.GetAssetPath(m_ItemCollection));
                AssetDatabase.SaveAssets();
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_ItemCollection));
            }

            EditorGUILayout.BeginHorizontal();
            GUI.SetNextControlName("CategoryName");
            m_CategoryName = EditorGUILayout.TextField("Name", m_CategoryName);
            GUI.enabled    = !string.IsNullOrEmpty(m_CategoryName) && (m_CategoryTreeView.TreeModal as CategoryCollectionModal).IsUniqueName(m_CategoryName);
            if (GUILayout.Button("Add", GUILayout.Width(100)) || (Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "CategoryName"))
            {
                // Create the new Category.
                var category = ScriptableObject.CreateInstance <Category>();
                category.ID   = Category.GenerateID();
                category.name = m_CategoryName;

                // Add the Category to the ItemCollection.
                Array.Resize(ref categories, categories.Length + 1);
                categories[categories.Length - 1] = category;
                m_ItemCollection.Categories       = categories;
                AssetDatabase.AddObjectToAsset(category, m_ItemCollection);

                // Reset.
                EditorUtility.SetDirty(m_ItemCollection);
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_ItemCollection));
                m_CategoryName = string.Empty;
                GUI.FocusControl("");
                m_CategoryTreeView.Reload();
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;
            GUILayout.Space(5);

            if (categories != null)
            {
                var guiRect = GUILayoutUtility.GetLastRect();
                var height  = m_MainManagerWindow.position.height - guiRect.yMax - 21;
                m_CategoryTreeView.searchString = m_CategorySearchField.OnGUI(new Rect(0, guiRect.yMax, m_MainManagerWindow.position.width - m_MainManagerWindow.MenuWidth - 2, 20), m_CategoryTreeView.searchString);
                m_CategoryTreeView.OnGUI(new Rect(0, guiRect.yMax + 20, m_MainManagerWindow.position.width - m_MainManagerWindow.MenuWidth - 1, height));
                // OnGUI doesn't update the GUILayout rect so add a blank space to account for it.
                GUILayout.Space(height + 10);
            }
        }
Ejemplo n.º 27
0
        public void OnGUI()
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            search = searchField.OnGUI(search);
            string searchLower = search.ToLower();

            EditorGUILayout.Separator();

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            int tagValue = tagValueProperty.intValue;

            for (int i = 0; i < tagNames.Length; i++)
            {
                string tagName          = tagNames[i];
                bool   isTagNameDefined = tagNames.IsTagDefined(i);
                string tagNameLower     = tagName.ToLower();

                bool boolValue = isMask ? tagValue.IsBitSet(i) : tagValue == i;

                bool show = isTagNameDefined || boolValue;

                if (search.Length > 0)
                {
                    show &= searchLower.Contains(tagNameLower) || tagNameLower.Contains(searchLower);
                }
                if (show)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.BeginHorizontal();

                    bool toggleValue = GUILayout.Toggle(boolValue, new GUIContent(tagName));

                    if (!isTagNameDefined)
                    {
                        GUILayout.FlexibleSpace();
                        GUIContent warning = EditorGUIUtility.IconContent("console.warnicon.sml");
                        warning.tooltip = "Undefined tag.";
                        GUILayout.Label(warning, GUILayout.Width(20));
                    }

                    EditorGUILayout.EndHorizontal();

                    if (EditorGUI.EndChangeCheck())
                    {
                        tagSelectedChangedCallback.Invoke(i, toggleValue);
                    }
                }
            }

            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 28
0
        private void DrawSearchBox()
        {
            EditorGUILayout.BeginHorizontal(searchBox, GUILayout.Height(30));
            var currentSearchText = searchField.OnGUI(searchText);

            EditorGUILayout.EndHorizontal();

            isDirty |= currentSearchText != searchText;

            searchText = currentSearchText;
        }
        public void DisplaySearchField()
        {
            var searchRect      = GUILayoutUtility.GetRect(100, 32);
            var tmpFilterString = ObjectSearchField.OnGUI(searchRect, FilterString);

            if (tmpFilterString != FilterString)
            {
                UpdateFilter(tmpFilterString);
                FilterString = tmpFilterString;
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Draws the ItemTypes editor.
        /// </summary>
        private void DrawItemTypes()
        {
            var itemTypes = m_ItemCollection.ItemTypes;

            EditorGUILayout.BeginHorizontal();
            GUI.SetNextControlName("ItemTypeName");
            m_ItemTypeName = EditorGUILayout.TextField("Name", m_ItemTypeName);
            GUI.enabled    = !string.IsNullOrEmpty(m_ItemTypeName) && (m_ItemTypeTreeView.TreeModal as ItemTypeCollectionModal).IsUniqueName(m_ItemTypeName);
            if (GUILayout.Button("Add", GUILayout.Width(100)) || (Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "ItemTypeName"))
            {
                // Create the new ItemType.
                var itemType = ScriptableObject.CreateInstance <ItemType>();
                itemType.name = m_ItemTypeName;
                if (m_ItemCollection.Categories != null && m_ItemCollection.Categories.Length > 0)
                {
                    itemType.CategoryIDs = new uint[] { m_ItemCollection.Categories[0].ID };
                }

                // Add the ItemType to the ItemCollection.
                Array.Resize(ref itemTypes, itemTypes != null ? itemTypes.Length + 1 : 1);
                itemType.ID = (uint)itemTypes.Length - 1;
                itemTypes[itemTypes.Length - 1] = itemType;
                m_ItemCollection.ItemTypes      = itemTypes;
                AssetDatabase.AddObjectToAsset(itemType, m_ItemCollection);
                AssetDatabase.SaveAssets();
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_ItemCollection));

                // Select the newly added item.
                m_ItemTypeTreeView.SetSelection(new List <int>()
                {
                    (int)itemType.ID
                }, TreeViewSelectionOptions.FireSelectionChanged);

                // Reset.
                EditorUtility.SetDirty(m_ItemCollection);
                m_ItemTypeName = string.Empty;
                GUI.FocusControl("");
                m_ItemTypeTreeView.Reload();
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;
            GUILayout.Space(5);

            if (itemTypes != null && itemTypes.Length > 0)
            {
                var guiRect = GUILayoutUtility.GetLastRect();
                var height  = m_MainManagerWindow.position.height - guiRect.yMax - 21;
                m_ItemTypeTreeView.searchString = m_ItemTypeSearchField.OnGUI(new Rect(0, guiRect.yMax, m_MainManagerWindow.position.width - m_MainManagerWindow.MenuWidth - 2, 20), m_ItemTypeTreeView.searchString);
                m_ItemTypeTreeView.OnGUI(new Rect(0, guiRect.yMax + 20, m_MainManagerWindow.position.width - m_MainManagerWindow.MenuWidth - 1, height));
                // OnGUI doesn't update the GUILayout rect so add a blank space to account for it.
                GUILayout.Space(height + 10);
            }
        }