Beispiel #1
0
            /// <summary>
            /// 执行,根据以上条件,筛选出符合条件资源路径
            /// </summary>
            /// <returns></returns>
            public AssetSearcherResult Execute()
            {
                string[]            assets = DirectoryUtil.GetAssetsByFileNameFilter(m_Folder, m_IncludeSubfolder, m_FileNameFilterRegex, new string[] { ".meta" });
                AssetSearcherResult result = new AssetSearcherResult();

                result.m_AssetPaths.AddRange(assets);
                return(result);
            }
        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="searcherResult"></param>
        /// <returns></returns>
        private AssetFilterResult ExecuteFilter(AssetSearcherResult searcherResult)
        {
            AssetFilterResult filterResult = new AssetFilterResult();

            for (int i = searcherResult.m_AssetPaths.Count - 1; i >= 0; --i)
            {
                string assetPath = searcherResult.m_AssetPaths[i];
                if (IsMatchFilter(assetPath))
                {
                    if (m_RemoveMatchFilterItem)
                    {
                        searcherResult.m_AssetPaths.RemoveAt(i);//为下个二级筛选器剔除重复
                    }
                    filterResult.m_AssetPaths.Add(assetPath);
                }
            }
            return(filterResult);
        }
Beispiel #3
0
        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="assemblyResult">资源集合返回结果</param>
        /// <returns>组搜索结果</returns>
        public virtual AssetGroupResult Execute(AssetAssemblyResult assemblyResult)
        {
            if (assemblyResult == null)
            {
                Debug.LogError("AssetGroup::Execute->Assembly Result is Null");
                return(null);
            }
            if (!m_IsEnable || m_FilterOperations.Count == 0)
            {
                return(null);
            }

            AssetSearcherResult searcherResult = new AssetSearcherResult();

            foreach (var searcher in m_AssetSearchers)
            {
                if (!UnityEditor.AssetDatabase.IsValidFolder(searcher.m_Folder))
                {
                    Debug.LogError($"AssetGroup::Execute->Folder is unvalid.groupName = {m_GroupName},folder={searcher.m_Folder}");
                    continue;
                }

                //逐个文件夹路径搜索条件,执行搜索
                searcherResult.m_AssetPaths.AddRange(searcher.Execute().m_AssetPaths);
            }

            AssetGroupResult groupResult = CreateGroupResult();

            groupResult.m_GroupName = m_GroupName;
            assemblyResult.m_GroupResults.Add(groupResult);

            foreach (var filterOperation in m_FilterOperations)
            {
                //逐个二次过滤条件,检查搜索
                AssetOperationResult[] operationResults = filterOperation.Execute(searcherResult, groupResult);
                if (operationResults != null)
                {
                    groupResult.m_OperationResults.AddRange(operationResults);
                }
            }

            return(groupResult);
        }
        public AssetOperationResult[] Execute(AssetSearcherResult searcherResult, AssetGroupResult groupResult)
        {
            AssetFilterResult           filterResult     = ExecuteFilter(searcherResult);
            List <AssetOperationResult> operationResults = new List <AssetOperationResult>();

            List <AssetOperationResult> results = new List <AssetOperationResult>();

            if (m_OperationComposeType == AssetComposeType.All)
            {
                //男的&& 大于25 && 上过学的
                AssetOperationResult operationResult = null;
                foreach (var assetOperation in m_AssetOperations)
                {
                    if (operationResult == null)
                    {
                        operationResult = assetOperation.Execute(filterResult, null);
                        if (operationResult != null)
                        {
                            results.Add(operationResult);
                        }
                    }
                    else
                    {
                        assetOperation.Execute(filterResult, operationResult);
                    }
                }
            }
            else
            {
                foreach (var assetOperation in m_AssetOperations)
                {
                    //男的|| 大于25 ||  上过学的
                    AssetOperationResult operationResult = assetOperation.Execute(filterResult, null);
                    if (operationResult != null)
                    {
                        results.Add(operationResult);
                    }
                }
            }

            return(results.ToArray());
        }