Version: 2022.3
言語: 日本語
public Search.ISearchList results ;

説明

Returns the list of all search results.

using UnityEngine;
using UnityEditor;
using UnityEditor.Search;

static class Example_ISearchView_results
{
    static ISearchList s_Results;

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

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

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

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