Example #1
0
        internal HierarchyProperty CreateHierarchyProperty()
        {
            HierarchyProperty property = new HierarchyProperty(k_HierarchyType);

            property.alphaSorted      = IsUsingAlphaSort();
            property.showSceneHeaders = PrefabStageUtility.GetCurrentPrefabStage() == null;
            if (AreScenesValid(scenes))
            {
                property.SetCustomScenes(scenes);
            }
            return(property);
        }
        internal HierarchyProperty CreateHierarchyProperty()
        {
            HierarchyProperty property = new HierarchyProperty(k_HierarchyType);

            property.alphaSorted      = IsUsingAlphaSort();
            property.showSceneHeaders = ShouldShowSceneHeaders();
            if (SceneHierarchyHooks.provideSubScenes != null)
            {
                property.SetSubScenes(SceneHierarchyHooks.provideSubScenes());
            }

            if (AreScenesValid(scenes))
            {
                property.SetCustomScenes(scenes);
            }
            return(property);
        }
        void SearchAllAssets(SearchFilter.SearchArea area)
        {
            const int k_MaxAddCount = 3000;

            if (m_HierarchyType == HierarchyType.Assets)
            {
                List <FilterResult> list = new List <FilterResult>();
                list.AddRange(m_Results);

                var maxAddCount = k_MaxAddCount;
                m_SearchFilter.searchArea = area;
                var enumerator = AssetDatabase.EnumerateAllAssets(m_SearchFilter);
                while (enumerator.MoveNext() && --maxAddCount >= 0)
                {
                    var result = new FilterResult();
                    CopyPropertyData(ref result, enumerator.Current);
                    list.Add(result);
                }

                m_Results = list.ToArray();
            }
            else if (m_HierarchyType == HierarchyType.GameObjects)
            {
                HierarchyProperty property = new HierarchyProperty(m_HierarchyType, false);
                property.SetSearchFilter(m_SearchFilter);

                if (m_SearchFilter.sceneHandles != null &&
                    m_SearchFilter.sceneHandles.Length > 0)
                {
                    property.SetCustomScenes(m_SearchFilter.sceneHandles);
                }

                int elements = property.CountRemaining(null);
                elements = Mathf.Min(elements, k_MaxAddCount);
                property.Reset();

                int i = m_Results.Length;
                System.Array.Resize(ref m_Results, m_Results.Length + elements);
                while (property.Next(null) && i < m_Results.Length)
                {
                    CopyPropertyData(ref m_Results[i], property);
                    i++;
                }
            }
        }
Example #4
0
        void SearchAllAssets(SearchFilter.SearchArea area)
        {
            if (m_HierarchyType == HierarchyType.Assets)
            {
                List <FilterResult> list = new List <FilterResult>();
                list.AddRange(m_Results);

                var maxAddCount = maxSearchAddCount;
                m_SearchFilter.searchArea = area;
                var enumerator = AssetDatabase.EnumerateAllAssets(m_SearchFilter);
                while (enumerator.MoveNext() && --maxAddCount >= 0)
                {
                    var result = new FilterResult();
                    CopyPropertyData(ref result, enumerator.Current);
                    list.Add(result);
                }

                m_Results = list.ToArray();
            }
            else if (m_HierarchyType == HierarchyType.GameObjects)
            {
                HierarchyProperty property = new HierarchyProperty(m_HierarchyType, false);
                m_SearchSessionHandler.BeginSession(() =>
                {
                    return(new SearchService.HierarchySearchContext
                    {
                        filter = m_SearchFilter,
                        rootProperty = property,
                        requiredTypeNames = m_SearchFilter.classNames,
                        requiredTypes = searchFilter.classNames.Select(name => TypeCache.GetTypesDerivedFrom <Object>().FirstOrDefault(t => name == t.FullName || name == t.Name))
                    });
                });

                var searchQuery   = m_SearchFilter.originalText;
                var searchContext = (SearchService.HierarchySearchContext)m_SearchSessionHandler.context;
                m_SearchSessionHandler.BeginSearch(searchQuery);

                if (m_SearchFilter.sceneHandles != null &&
                    m_SearchFilter.sceneHandles.Length > 0)
                {
                    property.SetCustomScenes(m_SearchFilter.sceneHandles);
                }

                var newResults = new List <FilterResult>();
                while (property.Next(null))
                {
                    if (!SearchService.Scene.Filter(searchQuery, property, searchContext))
                    {
                        continue;
                    }
                    FilterResult newResult = new FilterResult();
                    CopyPropertyData(ref newResult, property);
                    newResults.Add(newResult);
                }
                int elements = newResults.Count;
                elements = Mathf.Min(elements, maxSearchAddCount);

                int i = m_Results.Length;
                System.Array.Resize(ref m_Results, m_Results.Length + elements);
                for (var j = 0; j < elements && i < m_Results.Length; ++j, ++i)
                {
                    m_Results[i] = newResults[j];
                }

                m_SearchSessionHandler.EndSearch();
            }
        }