Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 3
0
 public static object GetSerializedPropertyValue(SearchSelectorArgs args)
 {
     if (!(args["propertyPath"] is string propertyPath))
     {
         return(null);
     }
     return(GetSerializedPropertyValue(args.current, propertyPath));
 }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        static object GetObjectName(SearchSelectorArgs args)
        {
            var go = args.current.ToObject <GameObject>();

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

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

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

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

            return(SceneFilterFaces(go) ?? null);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 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);
        }
Esempio n. 11
0
 static object GetEnabled(SearchSelectorArgs args)
 {
     return(GetEnabled(args.current));
 }
Esempio n. 12
0
 static object GetSearchItemFieldValue(SearchSelectorArgs args) => args.current.GetValue(args["fieldName"].ToString());