name | Name of the indexer. |
Creates a new default SearchIndexer.
using UnityEditor; using UnityEditor.Search; using UnityEngine; static class Example_SearchIndexer { [MenuItem("Examples/SearchIndexer/Class")] public static void Run() { // Create a search indexer var searchIndexer = new SearchIndexer("SearchIndexerExample"); // Indicate that searchIndexer is about to index documents searchIndexer.Start(); // Add some documents var unityDocumentIndex = searchIndexer.AddDocument("Unity Technologies"); // Index some words var baseScore = 42; searchIndexer.AddWord("unity", baseScore, unityDocumentIndex); searchIndexer.AddWord("is", baseScore, unityDocumentIndex); searchIndexer.AddWord("awesome", baseScore, unityDocumentIndex); // Indicate that searchIndexer is finished indexing documents and is ready to search. searchIndexer.Finish(); // Wait for the indexation to finish. while (!searchIndexer.IsReady()) ; // Search the index foreach (var result in searchIndexer.Search("uni")) Debug.Log($"Found document [{result.index}] {result.id} ({result.score})"); } }