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 = TypeComparison
            };

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

                callback(typeItem.Type, 0);
                return(true);
            }, position, null);
        static void PromptSearcher <T>(List <SearcherDatabase> databases, SearcherFilter filter,
                                       ISearcherAdapter adapter, Vector2 position, Action <T> callback) where T : ISearcherItemDataProvider
        {
            ApplyDatabasesFilter <T>(databases, filter);
            var searcher = new Searcher.Searcher(databases, adapter)
            {
                SortComparison = k_GraphElementSort
            };

            SearcherWindow.Show(EditorWindow.focusedWindow, searcher, item =>
            {
                if (item is T dataProvider)
                {
                    callback(dataProvider);
                    return(true);
                }

                return(false);
            }, position, null);
        }
        static void ApplyDatabasesFilter <T>(IEnumerable <SearcherDatabase> databases, SearcherFilter filter)
            where T : ISearcherItemDataProvider
        {
            foreach (var database in databases)
            {
                database.MatchFilter = (query, item) =>
                {
                    if (!(item is T dataProvider))
                    {
                        return(false);
                    }

                    if (filter == null || filter == SearcherFilter.Empty)
                    {
                        return(true);
                    }

                    return(filter.ApplyFilters(dataProvider.Data));
                };
            }
        }
예제 #4
0
 public static void RegisterConstant(this SearcherFilter filter, Func <TypeSearcherItemData, bool> func)
 {
     filter.Register(func, SearcherItemTarget.Constant);
 }
예제 #5
0
 public static void RegisterGraphAsset(this SearcherFilter filter, Func <GraphAssetSearcherItemData, bool> func)
 {
     filter.Register(func, SearcherItemTarget.GraphModel);
 }
예제 #6
0
 public static void RegisterVariable(this SearcherFilter filter, Func <TypeSearcherItemData, bool> func)
 {
     filter.Register(func, SearcherItemTarget.Variable);
 }
예제 #7
0
 public static void RegisterNode(this SearcherFilter filter, Func <NodeSearcherItemData, bool> func)
 {
     filter.Register(func, SearcherItemTarget.Node);
 }
예제 #8
0
 public static void RegisterStickyNote(this SearcherFilter filter, Func <SearcherItemData, bool> func)
 {
     filter.Register(func, SearcherItemTarget.StickyNote);
 }
예제 #9
0
 public static void RegisterBinaryOperator(this SearcherFilter filter, Func <BinaryOperatorSearcherItemData, bool> func)
 {
     filter.Register(func, SearcherItemTarget.BinaryOperator);
 }