版本:Unity 6 (6000.0)
语言英语
  • C#

ISearchView.results

建议更改

成功!

感谢您帮助我们改进 Unity 文档的质量。虽然我们无法接受所有提交内容,但我们确实会阅读用户提出的每一个建议更改,并在适用情况下进行更新。

关闭

提交失败

由于某些原因,您的建议更改无法提交。请<a>稍后再试</a>。感谢您抽出时间帮助我们改进 Unity 文档的质量。

关闭

取消

public Search.ISearchList results;

描述

返回所有搜索结果的列表。

using UnityEngine;
using UnityEditor;
using UnityEditor.Search;

static class Example_ISearchView_results
{
    static ISearchList s_Results;
    static ISearchView s_View;

    [MenuItem("Examples/ISearchView/results")]
    public static void Run()
    {
        s_View = SearchService.ShowContextual("asset");
        s_View.SetSearchText("t:MonoScript");

        // Keep result until the asynchronous Search query is totally processed.
        s_Results = s_View.results;
        EditorApplication.delayCall += DisplayResultsWhenReady;
    }

    public static void DisplayResultsWhenReady()
    {
        // Wait until results are ready to be processed.
        if (s_Results.pending || s_Results.Count == 0)
        {
            EditorApplication.delayCall += DisplayResultsWhenReady;
            return;
        }

        // Iterate over all results:
        foreach (var result in s_Results)
        {
            Debug.Log(result.GetLabel(s_View.context));
        }
    }
}