Version: 2021.2
public int keywordCount ;

描述

Returns the number keywords in the index.

using UnityEditor;
using UnityEditor.Search;
using UnityEngine;

static class Example_SearchIndexer_keywordCount
{
    [MenuItem("Examples/SearchIndexer/keywordCount")]
    public static void Run()
    {
        var searchIndexer = new SearchIndexer();
        searchIndexer.Start();
        {
            var di = searchIndexer.AddDocument("unity");

            // Add some properties and save the filter keywords.
            searchIndexer.AddProperty("is", "awesome", di, saveKeyword: true);
            searchIndexer.AddProperty("search", "powerful", di, saveKeyword: true);
        }
        searchIndexer.Finish(() => OnIndexReady(searchIndexer));
    }

    private static void OnIndexReady(SearchIndexer si)
    {
        Debug.Log($"Index contains {si.keywordCount} keywords");
    }
}

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