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

            if (!go)
            {
                return(null);
            }
            return(go.name);
        }
コード例 #6
0
        static object GetSceneObjectPath(SearchSelectorArgs args)
        {
            var go = args.current.ToObject <GameObject>();

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

            if (!go)
            {
                return(null);
            }
            return(go.tag);
        }
コード例 #8
0
        public static object SelectFaces(SearchSelectorArgs args)
        {
            var go = args.current.ToObject <GameObject>();

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

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