示例#1
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);
        }
        internal static object GetPrefabStatus(SearchItem item)
        {
            var prefab = item.ToObject();

            if (!prefab)
            {
                return(null);
            }
            return(PrefabUtility.GetPrefabInstanceStatus(prefab));
        }
        internal static object GetPrefabType(SearchItem item)
        {
            var prefab = item.ToObject();

            if (!prefab)
            {
                return(null);
            }
            return(PrefabUtility.GetPrefabAssetType(prefab));
        }
示例#4
0
        internal static SerializedProperty GetSerializedProperty(SearchItem item, string propertyPath, out SerializedObject so)
        {
            var go = item.ToObject <GameObject>();

            if (go)
            {
                foreach (var c in go.GetComponents <Component>())
                {
                    var v = FindProperty(c, propertyPath, out so);
                    if (v != null)
                    {
                        return(v);
                    }
                }
            }

            return(FindProperty(item.ToObject <AssetImporter>(), propertyPath, out so) ??
                   FindProperty(item.ToObject(), propertyPath, out so));
        }
示例#5
0
        private static object GetEnabled(SearchItem item)
        {
            var go = item.ToObject <GameObject>();

            if (!go)
            {
                return(null);
            }
            return(go.activeSelf);
        }
示例#6
0
        public static object SelectObjectStaticStates(SearchItem item)
        {
            var go = item.ToObject <GameObject>();

            if (!go)
            {
                return((StaticEditorFlags)0);
            }
            return(GameObjectUtility.GetStaticEditorFlags(go));
        }
示例#7
0
        public static object SceneSelectPositionZ(SearchItem item)
        {
            var go = item.ToObject <GameObject>();

            if (!go)
            {
                return(null);
            }
            return(Mathf.RoundToInt(go.transform.position.z));
        }
示例#8
0
        public static object SceneSelectPosition(SearchItem item)
        {
            var go = item.ToObject <GameObject>();

            if (!go)
            {
                return(null);
            }
            return(SceneFilterPosition(go));
        }
        internal static object GetPrefabBase(SearchItem item)
        {
            var prefab = item.ToObject();

            if (!prefab)
            {
                return(null);
            }
            var basePrefab = PrefabUtility.GetCorrespondingObjectFromSource(prefab);

            if (basePrefab == null || prefab == basePrefab)
            {
                return(null);
            }
            return(basePrefab);
        }
        internal static object GetPrefabRoot(SearchItem item)
        {
            var prefab = item.ToObject();

            if (!prefab)
            {
                return(null);
            }
            var rootPrefab = PrefabUtility.GetOriginalSourceOrVariantRoot(prefab);

            if (rootPrefab == null || prefab == rootPrefab)
            {
                return(null);
            }
            return(rootPrefab);
        }
        static bool IsObjectMatchingType(SearchItem item, Type filterType)
        {
            if (item == SearchItem.none)
            {
                return(true);
            }
            var obj = item.ToObject(filterType);

            if (!obj)
            {
                return(false);
            }
            var objType = obj.GetType();

            return(filterType.IsAssignableFrom(objType));
        }
示例#12
0
        private bool LoadEditor(SearchItem item, List <UnityEngine.Object> targets)
        {
            item.options |= SearchItemOptions.FullDescription;
            var itemObject = item.ToObject();

            item.options &= ~SearchItemOptions.FullDescription;
            if (!itemObject)
            {
                return(false);
            }

            if (itemObject is GameObject go)
            {
                var components = go.GetComponents <Component>();
                foreach (var c in components)
                {
                    if (!c || (c.hideFlags & HideFlags.HideInInspector) == HideFlags.HideInInspector)
                    {
                        continue;
                    }

                    targets.Add(c);
                }
            }
            else
            {
                targets.Add(itemObject);

                if (item.provider.id == "asset")
                {
                    var importer = AssetImporter.GetAtPath(item.id);
                    if (importer && importer.GetType() != typeof(AssetImporter))
                    {
                        targets.Add(importer);
                    }
                }
            }

            return(true);
        }
示例#13
0
        static object GetAssetName(SearchItem item)
        {
            var obj = item.ToObject();

            return(obj?.name);
        }