コード例 #1
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        _searchBy = (SearchType)EditorGUILayout.EnumPopup("Search by", _searchBy);
        EditorGUILayout.EndHorizontal();

        //display proper gui for current search type
        switch (_searchBy)
        {
        case (SearchType.Title):
            EditorGUILayout.BeginHorizontal();
            _searchTitle = EditorGUILayout.TextField(_searchTitle);
            DrawSearchButton();
            EditorGUILayout.EndHorizontal();
            break;

        case (SearchType.Color):
            EditorGUILayout.BeginHorizontal();
            _searchColor = (StickyNote.NoteColor)EditorGUILayout.EnumPopup(_searchColor);
            DrawSearchButton();
            EditorGUILayout.EndHorizontal();
            break;
        }

        EditorGUILayout.Space();

        //display search results
        if (_matchingNotes != null)
        {
            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, false);
            EditorGUILayout.BeginVertical(GUI.skin.box);
            if (_matchingNotes.Count > 0)
            {
                EditorGUILayout.LabelField(_matchingNotes.Count.ToString() + " results found!");

                _deletedNotes.Clear();
                for (int i = 0; i < _matchingNotes.Count; i++)
                {
                    if (_matchingNotes[i] == null)
                    {
                        _deletedNotes.Add(i);
                        continue;
                    }
                    DisplayNote(_matchingNotes[i]);
                }
                foreach (int i in _deletedNotes)
                {
                    _matchingNotes.RemoveAt(i);
                }
            }
            else
            {
                EditorGUILayout.LabelField("No results found :(");
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }

        DrawBottomSection();
    }
コード例 #2
0
        void OnGUI()
        {
            EditorGUILayout.BeginHorizontal();
            searchBy = (SearchType)EditorGUILayout.EnumPopup("Search by", searchBy);
            EditorGUILayout.EndHorizontal();

            //display proper gui for current search type
            switch (searchBy)
            {
            case (SearchType.title):
                searchTitle = EditorGUILayout.TextField(searchTitle);
                break;

            case (SearchType.color):
                searchColor = (StickyNote.NoteColor)EditorGUILayout.EnumPopup(searchColor);
                break;
            }

            //display search results
            if (matchingNotes != null)
            {
                scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                if (matchingNotes.Count > 0)
                {
                    EditorGUILayout.LabelField(matchingNotes.Count.ToString() + " results found!");
                    foreach (StickyNote n in matchingNotes)
                    {
                        DisplayNote(n);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("No results found :(");
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndScrollView();
            }

            GUILayout.FlexibleSpace();

            //display buttons
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Clear", GUILayout.Width(50f)))
            {
                matchingNotes = null;
            }
            if (GUILayout.Button("Search", GUILayout.Width(60f)))
            {
                PerformSearch();
            }
            EditorGUILayout.EndHorizontal();
        }