IEnumerable<SearchItem> 搜索项列表。项可以为 null,必须丢弃。
在搜索查询完成之前产生搜索项。
在搜索请求挂起时,可能会返回空值项。
[MenuItem("Examples/SearchService/Request List")] public static void RequestList() { ISearchList results = SearchService.Request("*.cs"); // It is important to note that when you request some search results, // that you need to enumerate them asynchronously using the returned search list. AsyncResultEnumerator.Fetch(results, item => Debug.Log(item)); } struct AsyncResultEnumerator { private Action<SearchItem> m_OnEnumerate; private IEnumerator<SearchItem> m_Iterator; public static AsyncResultEnumerator Fetch(ISearchList results, Action<SearchItem> onEnumerate) { return new AsyncResultEnumerator(results, onEnumerate); } public AsyncResultEnumerator(ISearchList results, Action<SearchItem> onEnumerate) { m_OnEnumerate = onEnumerate; m_Iterator = results.GetEnumerator(); EditorApplication.update += EnumerateResults; } private void EnumerateResults() { if (m_Iterator == null || !m_Iterator.MoveNext()) { m_Iterator = null; EditorApplication.update -= EnumerateResults; } else if (m_Iterator.Current != null) m_OnEnumerate(m_Iterator.Current); } }