Пример #1
0
 private void DrawSearchBar()
 {
     currentSearchQuery = EditorStyles.SearchBar(new Rect(innerPadding, innerPadding, position.width - innerPadding * 2f - 20f, 30f), currentSearchQuery, this, isSearching);
     if (GUI.GetNameOfFocusedControl() != "SearchField")
     {
         GUI.FocusControl("SearchField");
     }
 }
Пример #2
0
        public override void OnGUI()
        {
            base.OnGUI();

            searchQuery = EditorStyles.SearchBar(searchQuery, this, isSearching);
            if (focusOnSearch)
            {
                EditorGUI.FocusTextInControl("SearchField");
                focusOnSearch = false;
            }

            ShowInfoBox();
            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            for (int i = 0; i < objects.Count; i++)
            {
                var obj = objects[i];
                EditorGUILayout.BeginHorizontal();

                if (isSearching)
                {
                    string search = searchQuery.ToLower();
                    if (MatchesSearch(obj, search))
                    {
                        if (i == selectedIndex)
                        {
                            GUI.color = Color.green;
                        }

                        DrawObjectButton(obj);
                    }
                }
                else
                {
                    if (i == selectedIndex)
                    {
                        GUI.color = Color.green;
                    }

                    DrawObjectButton(obj);
                }

                GUI.color = Color.white;
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();
        }
Пример #3
0
        /// <summary>
        /// Draw the list, where item can be selected to edit
        /// </summary>
        protected virtual void DrawSidebar()
        {
            searchQuery = EditorStyles.SearchBar(searchQuery, window, isSearching);

            if (hideCreateItem == false)
            {
                GUI.color   = _createColor;
                GUI.enabled = canCreateItems;

                if (GUILayout.Button("Create " + singleName, (GUIStyle)"LargeButton"))
                {
                    CreateNewItem();
                }

                GUI.color   = Color.white;
                GUI.enabled = true;
            }


            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            // BEGIN ROW
            EditorGUILayout.BeginHorizontal();

            if (isSearching)
            {
                GUILayout.Label(_searchResultCount + " " + pluralName + " (search result)"); // , InventoryEditorStyles.titleStyle
            }
            else
            {
                GUILayout.Label(crudList.Count + " " + pluralName);
            }

            EditorGUILayout.EndHorizontal();
            // END ROW

            int x = 0;

            _searchResultCount = 0;
            foreach (var item in crudList)
            {
                if (item == null)
                {
                    continue;
                }

                if (item.Equals(selectedItem))
                {
                    GUI.color = Color.green;
                }

                if (isSearching)
                {
                    if (MatchesSearch(item, searchQuery))
                    {
                        _searchResultCount++;
                        DrawSidebarRow(item, x);
                    }
                }
                else
                {
                    DrawSidebarRow(item, x);
                }

                GUI.color = Color.white;
                x++;
            }

            if (_searchResultCount == 0 && isSearching)
            {
                selectedItem = null;
                window.Repaint();
            }

            EditorGUILayout.EndScrollView();
        }