Version: 2022.1
public Search.SearchDocument GetDocument (int index);

参数

index Valid index of the document to access.

返回

SearchDocument Indexed search document.

描述

Returns a search document by its index.

using UnityEditor;
using UnityEditor.Search;
using UnityEngine;

static class Example_SearchIndexer_GetDocument
{
    [MenuItem("Examples/SearchIndexer/GetDocument")]
    public static void Run()
    {
        var si = new SearchIndexer();
        si.Start();
        si.AddDocument("document 1");
        si.AddDocument("document 2");
        si.AddDocument("document 3");
        si.Finish(() =>
        {
            // Enumerate all documents
            for (int di = 0; di < si.documentCount; ++di)
            {
                var doc = si.GetDocument(di);
                Debug.Assert(doc.id.StartsWith("document"));
                Debug.Log(doc.id);
            }
        });
    }
}

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961