/// <summary> /// 获取打包收集的资源文件 /// </summary> public List <CollectAssetInfo> GetAllCollectAssets(AssetBundleCollectorGroup group) { // 注意:模拟构建模式下只收集主资源 if (AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild) { if (CollectorType != ECollectorType.MainAssetCollector) { return(new List <CollectAssetInfo>()); } } Dictionary <string, CollectAssetInfo> result = new Dictionary <string, CollectAssetInfo>(1000); bool isRawAsset = PackRuleName == nameof(PackRawFile); // 检测原生资源包的收集器类型 if (isRawAsset && CollectorType != ECollectorType.MainAssetCollector) { throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}"); } if (string.IsNullOrEmpty(CollectPath)) { throw new Exception($"The collect path is null or empty in group : {group.GroupName}"); } // 收集打包资源 if (AssetDatabase.IsValidFolder(CollectPath)) { string collectDirectory = CollectPath; string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory); foreach (string assetPath in findAssets) { if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath)) { if (result.ContainsKey(assetPath) == false) { var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset); result.Add(assetPath, collectAssetInfo); } else { throw new Exception($"The collecting asset file is existed : {assetPath} in collector : {CollectPath}"); } } } } else { string assetPath = CollectPath; if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath)) { var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset); result.Add(assetPath, collectAssetInfo); } else { throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}"); } } // 检测可寻址地址是否重复 if (AssetBundleCollectorSettingData.Setting.EnableAddressable) { HashSet <string> adressTemper = new HashSet <string>(); foreach (var collectInfoPair in result) { if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector) { string address = collectInfoPair.Value.Address; if (adressTemper.Contains(address) == false) { adressTemper.Add(address); } else { throw new Exception($"The address is existed : {address} in collector : {CollectPath}"); } } } } // 返回列表 return(result.Values.ToList()); }