Beispiel #1
0
        void FilterSettingsChanged()
        {
            SearchFilter filter = new SearchFilter();

            filter.SearchFieldStringToFilter(m_SearchFilter);
            if (!String.IsNullOrEmpty(m_RequiredType) && filter.classNames.Length == 0)
            {
                filter.classNames = new[] { m_RequiredType };
            }

            var hierarchyType = m_IsShowingAssets ? HierarchyType.Assets : HierarchyType.GameObjects;

            // We do not support cross scene references so ensure we only show game objects
            // from the same scene as the object being edited is part of.
            if (EditorSceneManager.preventCrossSceneReferences && hierarchyType == HierarchyType.GameObjects && m_ObjectBeingEdited != null)
            {
                var scene = GetSceneFromObject(m_ObjectBeingEdited);
                if (scene.IsValid())
                {
                    filter.scenePaths = new[] { scene.path }
                }
                ;
            }

            // For now, we don t want to display assets from Packages
            // Make sure we only search in Assets folder
            if (hierarchyType == HierarchyType.Assets)
            {
                filter.searchArea = SearchFilter.SearchArea.InAssetsOnly;
            }
            m_ListArea.Init(listPosition, hierarchyType, filter, true);
        }
Beispiel #2
0
        private void FilterSettingsChanged()
        {
            SearchFilter searchFilter = new SearchFilter();

            searchFilter.SearchFieldStringToFilter(this.m_SearchFilter);
            if (!string.IsNullOrEmpty(this.m_RequiredType))
            {
                searchFilter.classNames = new string[]
                {
                    this.m_RequiredType
                };
            }
            HierarchyType hierarchyType = (!this.m_IsShowingAssets) ? HierarchyType.GameObjects : HierarchyType.Assets;

            if (EditorSceneManager.preventCrossSceneReferences && hierarchyType == HierarchyType.GameObjects && this.m_ObjectBeingEdited != null)
            {
                Scene sceneFromObject = this.GetSceneFromObject(this.m_ObjectBeingEdited);
                if (sceneFromObject.IsValid())
                {
                    searchFilter.scenePaths = new string[]
                    {
                        sceneFromObject.path
                    };
                }
            }
            this.m_ListArea.Init(this.listPosition, hierarchyType, searchFilter, true);
        }
        void FilterSettingsChanged()
        {
            var filter = new SearchFilter();

            if (m_IsShowingAssets)
            {
                filter.searchArea = SearchFilter.SearchArea.AllAssets;
            }

            filter.SearchFieldStringToFilter(m_SearchFilter);
            if (!string.IsNullOrEmpty(m_RequiredType) && filter.classNames.Length == 0)
            {
                filter.classNames = new[] { m_RequiredType };
            }

            var hierarchyType = m_IsShowingAssets ? HierarchyType.Assets : HierarchyType.GameObjects;

            if (hierarchyType == HierarchyType.GameObjects)
            {
                if (m_ObjectBeingEdited != null)
                {
                    var scene = GetSceneFromObject(m_ObjectBeingEdited);
                    if (scene.IsValid())
                    {
                        // We do not support cross scene references so ensure we only show game objects
                        // from the same scene as the object being edited is part of.
                        // Also don't allow references to other scenes if object being edited
                        // is in a preview scene.
                        if (EditorSceneManager.IsPreviewScene(scene) || EditorSceneManager.preventCrossSceneReferences)
                        {
                            filter.sceneHandles = new[] { scene.handle }
                        }
                        ;
                    }
                }
                else
                {
                    // If we don't know which object is being edited, assume it's one in current stage.
                    PreviewSceneStage previewSceneStage = StageUtility.GetCurrentStage() as PreviewSceneStage;
                    if (previewSceneStage != null)
                    {
                        filter.sceneHandles = new[] { previewSceneStage.scene.handle };
                    }
                }
            }

            if (hierarchyType == HierarchyType.Assets)
            {
                // When AssemblyDefinitionAsset is the required type, don't skip hidden packages
                if (!string.IsNullOrEmpty(m_RequiredType) && m_RequiredType == typeof(AssemblyDefinitionAsset).Name)
                {
                    m_SkipHiddenPackages = false;
                }
                filter.skipHidden = m_SkipHiddenPackages;
            }

            m_ListArea.Init(listPosition, hierarchyType, filter, true);
        }
Beispiel #4
0
        private void FilterSettingsChanged()
        {
            SearchFilter searchFilter = new SearchFilter();

            searchFilter.SearchFieldStringToFilter(this.m_SearchFilter);
            if (!string.IsNullOrEmpty(this.m_RequiredType))
            {
                searchFilter.classNames = new string[] { this.m_RequiredType };
            }
            this.m_ListArea.Init(this.listPosition, !this.m_IsShowingAssets ? HierarchyType.GameObjects : HierarchyType.Assets, searchFilter, true);
        }
        void FilterSettingsChanged()
        {
            var filter = new SearchFilter();

            if (m_IsShowingAssets)
            {
                filter.searchArea = SearchFilter.SearchArea.AllAssets;
            }

            filter.SearchFieldStringToFilter(m_SearchFilter);
            if (!string.IsNullOrEmpty(m_RequiredType) && filter.classNames.Length == 0)
            {
                filter.classNames = new[] { m_RequiredType };
            }

            var hierarchyType = m_IsShowingAssets ? HierarchyType.Assets : HierarchyType.GameObjects;

            // We do not support cross scene references so ensure we only show game objects
            // from the same scene as the object being edited is part of.
            if (EditorSceneManager.preventCrossSceneReferences && hierarchyType == HierarchyType.GameObjects && m_ObjectBeingEdited != null)
            {
                var scene = GetSceneFromObject(m_ObjectBeingEdited);
                if (scene.IsValid())
                {
                    filter.sceneHandles = new[] { scene.handle }
                }
                ;
            }

            if (hierarchyType == HierarchyType.Assets)
            {
                // When AssemblyDefinitionAsset is the required type, don't skip hidden packages
                if (!string.IsNullOrEmpty(m_RequiredType) && m_RequiredType == typeof(AssemblyDefinitionAsset).Name)
                {
                    m_SkipHiddenPackages = false;
                }
                filter.skipHidden = m_SkipHiddenPackages;
            }

            m_ListArea.Init(listPosition, hierarchyType, filter, true);
        }
        void FilterSettingsChanged()
        {
            var filter = new SearchFilter();

            if (m_IsShowingAssets)
            {
                filter.searchArea = SearchFilter.SearchArea.AllAssets;
            }

            filter.SearchFieldStringToFilter(m_SearchFilter);
            if (filter.classNames.Length == 0 && m_RequiredTypes.All(type => !string.IsNullOrEmpty(type)))
            {
                filter.classNames = m_RequiredTypes;
            }

            var hierarchyType = m_IsShowingAssets ? HierarchyType.Assets : HierarchyType.GameObjects;

            if (hierarchyType == HierarchyType.GameObjects)
            {
                if (m_ObjectBeingEdited != null)
                {
                    var scene = GetSceneFromObject(m_ObjectBeingEdited);
                    if (scene.IsValid())
                    {
                        // We do not support cross scene references so ensure we only show game objects
                        // from the same scene as the object being edited is part of.
                        // Also don't allow references to other scenes if object being edited
                        // is in a preview scene.
                        if (EditorSceneManager.IsPreviewScene(scene) || EditorSceneManager.preventCrossSceneReferences)
                        {
                            filter.sceneHandles = new[] { scene.handle }
                        }
                        ;
                    }
                }
                else
                {
                    // If we don't know which object is being edited, assume it's one in current stage.
                    PreviewSceneStage previewSceneStage = StageUtility.GetCurrentStage() as PreviewSceneStage;
                    if (previewSceneStage != null)
                    {
                        filter.sceneHandles = new[] { previewSceneStage.scene.handle };
                    }
                }
            }

            if (hierarchyType == HierarchyType.Assets)
            {
                // When AssemblyDefinitionAsset is the required type, don't skip hidden packages
                foreach (var type in m_RequiredTypes)
                {
                    if (!string.IsNullOrEmpty(type) && type == typeof(AssemblyDefinitionAsset).Name)
                    {
                        m_SkipHiddenPackages = false;
                        break;
                    }
                }
                filter.skipHidden = m_SkipHiddenPackages;
            }

            bool hasObject     = false;
            var  requiredTypes = new List <Type>();
            var  objectTypes   = TypeCache.GetTypesDerivedFrom <UnityEngine.Object>();

            foreach (var type in m_RequiredTypes)
            {
                foreach (var objectType in objectTypes)
                {
                    if (objectType.Name == type)
                    {
                        requiredTypes.Add(objectType);
                    }
                    else if (!hasObject)
                    {
                        requiredTypes.Add(typeof(UnityObject));
                        hasObject = true;
                    }
                }
            }
            m_ListArea.InitForSearch(listPosition, hierarchyType, filter, true, s =>
            {
                foreach (var type in requiredTypes)
                {
                    var asset = AssetDatabase.LoadAssetAtPath(s, type);
                    if (asset != null && asset.GetInstanceID() != 0)
                    {
                        return(asset.GetInstanceID());
                    }
                }
                return(0);
            }, m_LegacySearchSessionOptions);
        }