Exemple #1
0
        public static object GetMaterialPropertyValue(SearchSelectorArgs args)
        {
            if (!(args["propertyPath"] is string propertyPath))
            {
                return(null);
            }

            var item     = args.current;
            var material = item.ToObject <Material>();

            if (!material)
            {
                return(null);
            }

            var matProp = MaterialEditor.GetMaterialProperty(new Object[] { material }, propertyPath);

            if (matProp == null || matProp.name == null)
            {
                var materialProperties = MaterialEditor.GetMaterialProperties(new Object[] { material });
                for (var i = 0; i < materialProperties.Length; i++)
                {
                    if (!materialProperties[i].name.EndsWith(propertyPath, System.StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    matProp = materialProperties[i];
                    break;
                }
            }

            return(GetMaterialPropertyValue(matProp));
        }
Exemple #2
0
        internal static MaterialProperty GetMaterialProperty(SearchItem item, SearchColumn column)
        {
            var mat = item.ToObject <Material>();

            if (!mat)
            {
                return(null);
            }

            foreach (var m in SelectorManager.Match(column.selector, item.provider?.type))
            {
                var selectorArgs = new SearchSelectorArgs(m, item);
                if (selectorArgs.name == null)
                {
                    continue;
                }

                if (!mat.HasProperty(selectorArgs.name))
                {
                    continue;
                }

                return(MaterialEditor.GetMaterialProperty(new Object[] { mat }, selectorArgs.name));
            }

            return(null);
        }
Exemple #3
0
 public static object GetSerializedPropertyValue(SearchSelectorArgs args)
 {
     if (!(args["propertyPath"] is string propertyPath))
     {
         return(null);
     }
     return(GetSerializedPropertyValue(args.current, propertyPath));
 }
        public static object SelectValue(SearchItem item, SearchContext context, string selectorName, out string suggestedSelectorName)
        {
            suggestedSelectorName = selectorName;
            if (item.TryGetValue(selectorName, context, out var field))
            {
                return(field.value);
            }

            if (string.IsNullOrEmpty(selectorName))
            {
                return(null);
            }

            using (var view = SearchMonitor.GetView())
            {
                if (view.TryLoadProperty(item.key, selectorName, out var recordKey, out var cv, out suggestedSelectorName))
                {
                    return(cv);
                }

                string localSuggestedSelectorName = null;
                string providerType = item.provider.type;
                var    itemValue    = TaskEvaluatorManager.EvaluateMainThread(() =>
                {
                    foreach (var m in Match(selectorName, providerType))
                    {
                        var selectorArgs  = new SearchSelectorArgs(m, item);
                        var selectedValue = m.selector.select(selectorArgs);
                        if (selectedValue != null)
                        {
                            if (selectorArgs.name != null)
                            {
                                localSuggestedSelectorName = selectorArgs.name;
                            }
                            return(selectedValue);
                        }
                    }

                    return(null);
                });

                if (itemValue == null)
                {
                    return(null);
                }

                if (!string.IsNullOrEmpty(localSuggestedSelectorName))
                {
                    suggestedSelectorName = localSuggestedSelectorName;
                }

                view.StoreProperty(recordKey, itemValue, suggestedSelectorName);

                return(itemValue);
            }
        }
        static object GetObjectName(SearchSelectorArgs args)
        {
            var go = args.current.ToObject <GameObject>();

            if (!go)
            {
                return(null);
            }
            return(go.name);
        }
        static object GetSceneObjectPath(SearchSelectorArgs args)
        {
            var go = args.current.ToObject <GameObject>();

            if (!go)
            {
                return(null);
            }
            return(SearchUtils.GetHierarchyPath(go, false));
        }
        static object GetSceneObjectTag(SearchSelectorArgs args)
        {
            var go = args.current.ToObject <GameObject>();

            if (!go)
            {
                return(null);
            }
            return(go.tag);
        }
        public static object SelectFaces(SearchSelectorArgs args)
        {
            var go = args.current.ToObject <GameObject>();

            if (!go)
            {
                return(null);
            }

            return(SceneFilterFaces(go) ?? null);
        }
        static object GetSceneObjectType(SearchSelectorArgs args)
        {
            var go = args.current.ToObject <GameObject>();

            if (!go)
            {
                return(null);
            }
            var components = go.GetComponents <Component>();

            if (components.Length == 0)
            {
                return(go.GetType().Name);
            }
            else if (components.Length == 1)
            {
                return(components[0]?.GetType().Name);
            }
            return(components[1]?.GetType().Name);
        }
Exemple #10
0
        internal static SerializedProperty GetSerializedProperty(SearchItem item, SearchColumn column, out SerializedObject so)
        {
            foreach (var m in SelectorManager.Match(column.selector, item.provider?.type))
            {
                var selectorArgs = new SearchSelectorArgs(m, item);
                if (selectorArgs.name == null)
                {
                    continue;
                }
                var property = GetSerializedProperty(item, selectorArgs.name, out so);
                if (property == null)
                {
                    so?.Dispose();
                    continue;
                }

                so.UpdateIfRequiredOrScript();
                return(property);
            }

            so = null;
            return(null);
        }
 static object GetEnabled(SearchSelectorArgs args)
 {
     return(GetEnabled(args.current));
 }
 static object GetSearchItemFieldValue(SearchSelectorArgs args) => args.current.GetValue(args["fieldName"].ToString());