/// <summary> /// Execute a search request that will fetch search results asynchronously. /// </summary> /// <param name="context">Search context used to track asynchronous request.</param> /// <param name="options">Options defining how the query will be performed</param> /// <returns>Asynchronous list of search items.</returns> public static ISearchList Request(SearchContext context, SearchFlags options = SearchFlags.None) { ISearchList results = null; if (!InternalEditorUtility.CurrentThreadIsMainThread()) { results = new ConcurrentSearchList(context); Dispatcher.Enqueue(() => { results.AddItems(GetItems(context, options)); (results as ConcurrentSearchList)?.GetItemsDone(); }); return(results); } if (options.HasAny(SearchFlags.Sorted)) { results = new SortedSearchList(context); } else { results = new AsyncSearchList(context); } results.AddItems(GetItems(context, options)); return(results); }
public SearchSelection(IEnumerable <SearchItem> items) { m_Items = new List <SearchItem>(items); m_Selection = new List <int>(); for (int i = 0; i < m_Items.Count; ++i) { m_Selection.Add(i); } m_List = null; }
private void AddSearchItemsAsConverterAssetEntries(ISearchList searchItems, InitializeConverterContext context) { foreach (var searchItem in searchItems) { if (searchItem == null || !GlobalObjectId.TryParse(searchItem.id, out var globalId)) { continue; } var description = searchItem.provider.fetchDescription(searchItem, searchItem.context); var item = new ConverterItemDescriptor() { name = description.Split('/').Last().Split('.').First(), info = $"{ReturnType(globalId)}", }; guids.Add(globalId.ToString()); context.AddAssetToConvert(item); } }
/// <summary> /// Execute a search request that will fetch search results asynchronously. /// </summary> /// <param name="context">Search context used to track asynchronous request.</param> /// <param name="options">Options defining how the query will be performed</param> /// <returns>Asynchronous list of search items.</returns> public static ISearchList Request(SearchContext context, SearchFlags options = SearchFlags.None) { if (options.HasFlag(SearchFlags.Synchronous)) { throw new NotSupportedException($"Use {nameof(SearchService)}.{nameof(GetItems)}(context, " + $"{nameof(SearchFlags)}.{nameof(SearchFlags.Synchronous)}) to fetch items synchronously."); } ISearchList results = null; if (options.HasFlag(SearchFlags.Sorted)) { results = new SortedSearchList(context); } else { results = new AsyncSearchList(context); } results.AddItems(GetItems(context, options)); return(results); }
/// <summary> /// Create a new SearchSelection /// </summary> /// <param name="selection">Current list of selected SearchItem indices.</param> /// <param name="filteredItems">List of SearchItem displayed in QuickSearch.</param> public SearchSelection(IList <int> selection, ISearchList filteredItems) { m_Selection = selection; m_List = filteredItems; }