예제 #1
0
 internal IEnumerable <SearchItem> CreateSearchItems(SearchProvider searchExpressionProvider)
 {
     foreach (var item in items)
     {
         var newItem = searchExpressionProvider.CreateItem(Guid.NewGuid().ToString("N"));
         for (int i = 0; i < item.fields.Length; ++i)
         {
             newItem.SetField(item.fields[i].name, item.fields[i].value.TryConvert());
         }
         yield return(newItem);
     }
 }
예제 #2
0
        static IEnumerable <SearchItem> FetchTemplates(SearchContext context, SearchProvider provider)
        {
            long       score     = 0;
            var        templates = SceneTemplateUtils.GetSceneTemplateInfos();
            List <int> matches   = new List <int>();

            foreach (var t in templates)
            {
                var id = t.sceneTemplate?.GetInstanceID().ToString() ?? t.name;
                if (string.IsNullOrEmpty(context.searchQuery) || FuzzySearch.FuzzyMatch(context.searchQuery, $"{t.name} {t.description}", ref score, matches))
                {
                    yield return(provider.CreateItem(context, id, ~(int)score, t.name, t.description, t.thumbnail, t));
                }
                score++;
            }
        }
예제 #3
0
 public static new SearchItem CreateItem(SearchContext context, string id, int score, string label, string description, Texture2D thumbnail, object @ref)
 {
     return(s_Provider.CreateItem(context, id, score, label, description, thumbnail, @ref));
 }