示例#1
0
 public static void InitializeColumn(SearchColumn column)
 {
     column.provider = "";
     column.getter   = args => { args.item.TryGetValue(args.column.selector, out var field); return(field.value); };
     column.setter   = null;
     column.drawer   = args =>
     {
         if (args.value == null)
         {
             return(null);
         }
         if (args.value is SearchReport.ObjectValue v)
         {
             if (v.objectValue == null)
             {
                 PropertyTable.DefaultDrawing(args.rect, args.column, v.fallbackString);
             }
             else
             {
                 PropertySelectors.DrawObjectReference(args.rect, v.objectValue);
             }
         }
         else if (args.value is Color c)
         {
             return(EditorGUI.ColorField(args.rect, c, showEyedropper: false, showAlpha: true));
         }
         else
         {
             PropertyTable.DefaultDrawing(args.rect, args.column, args.value);
         }
         return(args.value);
     };
     column.comparer = null;
 }
示例#2
0
 public static IEnumerable <SearchColumn> Enumerate(IEnumerable <SearchItem> items)
 {
     return(PropertySelectors.Enumerate(items).Concat(new[]
     {
         new SearchColumn("GameObject/Enabled", "enabled", "GameObject/Enabled", options: SearchColumnFlags.TextAlignmentCenter)
     }));
 }
示例#3
0
        private IEnumerable <SearchProposition> FetchPropositions(SearchContext context, SearchPropositionOptions options)
        {
            var category = options.HasAny(SearchPropositionFlags.QueryBuilder) ? "Expressions" : null;

            foreach (var e in EvaluatorManager.evaluators)
            {
                var help = e.description ?? "Expression evaluator";
                yield return(new SearchProposition(category: category, $"{e.name}{{}}", $"{e.name.ToLowerInvariant()}{{\t}}", help, 1));
            }

            if (options.tokens.Length > 0 && options.tokens[0].Length > 0)
            {
                var token = options.tokens[0][0];
                if (token == '#')
                {
                    foreach (var c in PropertySelectors.Enumerate(context.searchView.results.Take(10)))
                    {
                        yield return(new SearchProposition(category: category, label: $"{token}{c.content.text ?? c.path}", $"{c.selector}\t", $"Property ({c.selector})"));
                    }
                }

                if (token == '@')
                {
                    foreach (var s in SelectorManager.selectors.Where(s => s.printable))
                    {
                        yield return(new SearchProposition(category: category, label: $"{token}{s.label}", help: s.description ?? "Selector", replacement: $"@{s.label}\t"));
                    }
                }
            }
        }
示例#4
0
 internal static string ExtractDataValue(object data, out ExportedType type, bool convertForCSV = false)
 {
     if (data == null)
     {
         type = ExportedType.None;
         return(string.Empty);
     }
     else if (data is UnityEngine.Object o)
     {
         type = ExportedType.ObjectReference;
         string objectToString = o.name;
         if (string.IsNullOrEmpty(o.name))
         {
             objectToString = AssetDatabase.GetAssetPath(o);
             if (string.IsNullOrEmpty(objectToString))
             {
                 objectToString = o.GetType().ToString();
             }
         }
         if (convertForCSV)
         {
             return(o.ToString());
         }
         else
         {
             return($"{GlobalObjectId.GetGlobalObjectIdSlow(o).ToString()};{objectToString}");
         }
     }
     else if (data is SerializedProperty sp)
     {
         return(ExtractDataValue(PropertySelectors.GetSerializedPropertyValue(sp), out type));
     }
     else if (data is MaterialProperty mp)
     {
         return(ExtractDataValue(MaterialSelectors.GetMaterialPropertyValue(mp), out type));
     }
     else if (data is Color color)
     {
         type = ExportedType.Color;
         return('#' + ColorUtility.ToHtmlStringRGBA(color));
     }
     else
     {
         if (data is bool)
         {
             type = ExportedType.Bool;
         }
         else if (Utils.TryGetNumber(data, out var number))
         {
             type = ExportedType.Number;
         }
         else
         {
             type = ExportedType.String;
         }
         return(data.ToString());
     }
 }
示例#5
0
 public static IEnumerable <SearchColumn> Enumerate(IEnumerable <SearchItem> items)
 {
     #if USE_SEARCH_MODULE
     return(PropertySelectors.Enumerate(FilterItems(items, 5))
            .Concat(MaterialSelectors.Enumerate(FilterItems(items, 20))));
     #else
     return(PropertySelectors.Enumerate(FilterItems(items, 5)));
     #endif
 }
示例#6
0
 public static IEnumerable <SearchColumn> Enumerate(IEnumerable <SearchItem> items)
 {
     return(PropertySelectors.Enumerate(FilterItems(items, 5))
            .Concat(MaterialSelectors.Enumerate(FilterItems(items, 20))));
 }