예제 #1
0
        public static void ShowTypes(Stencil stencil, Vector2 position, Action <TypeHandle, int> callback,
                                     SearcherFilter userFilter = null)
        {
            var databases = stencil.GetSearcherDatabaseProvider().GetTypesSearcherDatabases();

            foreach (var database in databases)
            {
                database.MatchFilter = (query, item) =>
                {
                    if (!(item is TypeSearcherItem typeItem))
                    {
                        return(false);
                    }

                    var filter = stencil.GetSearcherFilterProvider()?.GetTypeSearcherFilter();
                    var res    = true;

                    if (filter != null)
                    {
                        res &= GetFilterResult(filter, typeItem.Data);
                    }

                    if (userFilter != null)
                    {
                        res &= GetFilterResult(userFilter, typeItem.Data);
                    }

                    return(res);
                };
            }

            var searcher = new Searcher.Searcher(databases, k_TypeAdapter)
            {
                SortComparison = k_TypeSort
            };

            SearcherWindow.Show(EditorWindow.focusedWindow, searcher, item =>
            {
                if (!(item is TypeSearcherItem typeItem))
                {
                    return(false);
                }

                callback(typeItem.Type, 0);
                return(true);
            }, position, null);