static SettingsProviderCache() { value = FetchSettingsProviders() .Select(provider => new SettingsProviderInfo() { path = provider.settingsPath, label = provider.label, scope = provider.scope, searchables = new[] { provider.settingsPath, provider.label } .Concat(provider.keywords) .Where(s => !string.IsNullOrEmpty(s)) .Select(s => Utils.FastToLower(s)).ToArray() }) .ToArray(); var iconName = "Filter Icon"; var icon = Utils.LoadIcon(iconName); var scopeValues = Enum.GetNames(typeof(SettingsScope)).Select(n => Utils.FastToLower(n)); queryEngine = new QueryEngine <SettingsProviderInfo>(); queryEngine.SetSearchDataCallback(info => info.searchables, s => Utils.FastToLower(s), StringComparison.Ordinal); queryEngine.SetFilter("scope", info => info.scope, new[] { ":", "=", "!=", "<", ">", "<=", ">=" }) .SetGlobalPropositionData(category: "Scope", priority: 0, icon: icon, color: QueryColors.typeIcon) .AddOrUpdatePropositionData(label: "Project", replacement: "scope:" + SearchUtils.GetListMarkerReplacementText("project", scopeValues, iconName, QueryColors.typeIcon), help: "Search project settings") .AddOrUpdatePropositionData(label: "User", replacement: "scope:" + SearchUtils.GetListMarkerReplacementText("user", scopeValues, iconName, QueryColors.typeIcon), help: "Search user settings"); queryEngine.AddOperatorHandler(":", (SettingsScope ev, SettingsScope fv, StringComparison sc) => ev.ToString().IndexOf(fv.ToString(), sc) != -1); queryEngine.AddOperatorHandler(":", (SettingsScope ev, string fv, StringComparison sc) => ev.ToString().IndexOf(fv, sc) != -1); queryEngine.AddOperatorHandler("=", (SettingsScope ev, SettingsScope fv) => ev == fv); queryEngine.AddOperatorHandler("!=", (SettingsScope ev, SettingsScope fv) => ev != fv); queryEngine.AddOperatorHandler("<", (SettingsScope ev, SettingsScope fv) => ev < fv); queryEngine.AddOperatorHandler(">", (SettingsScope ev, SettingsScope fv) => ev > fv); queryEngine.AddOperatorHandler("<=", (SettingsScope ev, SettingsScope fv) => ev <= fv); queryEngine.AddOperatorHandler(">=", (SettingsScope ev, SettingsScope fv) => ev >= fv); }
public override string ToString() { var markerReplacement = SearchUtils.GetListMarkerReplacementText(value, m_Choices, m_IconName, m_BackgroundColor); return($"{id}{op}{markerReplacement}"); }
public override void SetupQueryEnginePropositions() { var goIcon = Utils.LoadIcon("GameObject Icon"); m_QueryEngine.GetFilter("active") .AddOrUpdatePropositionData(category: "GameObject", label: "Active", replacement: "active=true", help: "Search active objects", icon: goIcon, color: QueryColors.filter); m_QueryEngine.GetFilter("size") .AddOrUpdatePropositionData(category: "GameObject", label: "Volume Size", replacement: "size>1", help: "Search object by volume size", icon: goIcon, color: QueryColors.filter);; m_QueryEngine.GetFilter("components") .AddOrUpdatePropositionData(category: "GameObject", label: "Components count", replacement: "components>1", help: "Search object with more than # components", icon: goIcon, color: QueryColors.filter);;; m_QueryEngine.GetFilter("id") .AddOrUpdatePropositionData(category: "GameObject", label: "InstanceID", replacement: "id=0", help: "Search object with InstanceID", icon: goIcon, color: QueryColors.filter); m_QueryEngine.GetFilter("path") .AddOrUpdatePropositionData(category: "GameObject", label: "Path", replacement: "path=/root/children1", help: "Search object with Transform path", icon: goIcon, color: QueryColors.filter); var layerFilter = m_QueryEngine.GetFilter("layer") .SetGlobalPropositionData(category: "Layers", icon: Utils.LoadIcon("GUILayer Icon"), color: QueryColors.typeIcon, type: typeof(QueryLayerBlock)); for (var i = 0; i < 32; ++i) { var layerName = InternalEditorUtility.GetLayerName(i); if (!string.IsNullOrEmpty(layerName)) { layerFilter.AddOrUpdatePropositionData(label: ObjectNames.NicifyVariableName(layerName), data: layerName, replacement: $"<$layer:{i}, {layerName}$>"); } } var tagFilter = m_QueryEngine.GetFilter("tag") .SetGlobalPropositionData(category: "Tags", icon: Utils.LoadIcon("AssetLabelIcon"), color: QueryColors.typeIcon); foreach (var t in InternalEditorUtility.tags) { tagFilter.AddOrUpdatePropositionData(category: "Tags", label: ObjectNames.NicifyVariableName(t), replacement: "tag=" + SearchUtils.GetListMarkerReplacementText(t, InternalEditorUtility.tags, "AssetLabelIcon", QueryColors.typeIcon)); } m_QueryEngine.GetFilter("prefab") .AddPropositionsFromFilterType(icon: Utils.LoadIcon("Prefab Icon"), category: "Prefabs", priority: 0, type: typeof(QueryListMarkerBlock), color: QueryColors.typeIcon); var sceneIcon = Utils.LoadIcon("SceneAsset Icon"); m_QueryEngine.GetFilter("ref") .AddOrUpdatePropositionData(category: "Reference", label: "Reference By Path (Object)", replacement: "ref=<$object:none,UnityEngine.Object$>", help: "Find all objects referencing a specific asset.", icon: sceneIcon, color: QueryColors.filter) .AddOrUpdatePropositionData(category: "Reference", label: "Reference By Instance ID (Number)", replacement: "ref=1000", help: "Find all objects referencing a specific instance ID (Number).", icon: sceneIcon, color: QueryColors.filter) .AddOrUpdatePropositionData(category: "Reference", label: "Reference By Asset Expression", replacement: "ref={p: }", help: "Find all objects referencing for a given asset search.", icon: sceneIcon, color: QueryColors.filter); m_QueryEngine.AddPropositionsFromFilterAttributes <GameObject, SceneQueryEngineFilterAttribute>(category: "Custom Scene Filters", icon: sceneIcon, color: QueryColors.filter, propositionTransformation: proposition => { return(new SearchProposition(category: proposition.category, label: proposition.label, replacement: proposition.replacement, help: proposition.help, data: proposition.data, priority: proposition.priority, icon: proposition.icon, type: proposition.type, color: proposition.color, moveCursor: proposition.moveCursor)); }); }