diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
index c18a5ee..af615e8 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
@@ -51,7 +51,7 @@ namespace YooAsset.Editor
new TaskCopyRawFile(), //拷贝原生文件
new TaskVerifyBuildResult(), //验证构建结果
new TaskEncryption(), //加密资源文件
- new TaskUpdateBuildInfo(), //更新构建信息
+ new TaskUpdatePatchInfo(), //更新补丁信息
new TaskCreatePatchManifest(), //创建清单文件
new TaskCreateReport(), //创建报告文件
new TaskCreatePatchPackage(), //制作补丁包
@@ -68,7 +68,7 @@ namespace YooAsset.Editor
new TaskCopyRawFile(), //拷贝原生文件
new TaskVerifyBuildResult_SBP(), //验证构建结果
new TaskEncryption(), //加密资源文件
- new TaskUpdateBuildInfo(), //更新构建信息
+ new TaskUpdatePatchInfo(), //更新补丁信息
new TaskCreatePatchManifest(), //创建清单文件
new TaskCreateReport(), //创建报告文件
new TaskCreatePatchPackage(), //制作补丁包
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
index 55633f4..e28666f 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
@@ -32,9 +32,15 @@ namespace YooAsset.Editor
public string ShadersBundleName;
///
- /// 资源包列表
+ /// 资源包信息列表
///
- public readonly List BundleInfos = new List(10000);
+ public Dictionary.ValueCollection Collection
+ {
+ get
+ {
+ return _bundleInfoDic.Values;
+ }
+ }
///
@@ -54,25 +60,10 @@ namespace YooAsset.Editor
{
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
newBundleInfo.PackAsset(assetInfo);
- BundleInfos.Add(newBundleInfo);
_bundleInfoDic.Add(bundleName, newBundleInfo);
}
}
- ///
- /// 获取构建管线里需要的数据
- ///
- public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
- {
- List builds = new List(BundleInfos.Count);
- foreach (var bundleInfo in BundleInfos)
- {
- if (bundleInfo.IsRawFile == false)
- builds.Add(bundleInfo.CreatePipelineBuild());
- }
- return builds.ToArray();
- }
-
///
/// 是否包含资源包
///
@@ -93,6 +84,20 @@ namespace YooAsset.Editor
throw new Exception($"Not found bundle : {bundleName}");
}
+ ///
+ /// 获取构建管线里需要的数据
+ ///
+ public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
+ {
+ List builds = new List(_bundleInfoDic.Count);
+ foreach (var bundleInfo in _bundleInfoDic.Values)
+ {
+ if (bundleInfo.IsRawFile == false)
+ builds.Add(bundleInfo.CreatePipelineBuild());
+ }
+ return builds.ToArray();
+ }
+
///
/// 创建着色器信息类
///
@@ -101,7 +106,6 @@ namespace YooAsset.Editor
if (IsContainsBundle(shadersBundleName) == false)
{
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
- BundleInfos.Add(shaderBundleInfo);
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs
deleted file mode 100644
index c4979f3..0000000
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-using System;
-using System.Linq;
-using System.Collections;
-using System.Collections.Generic;
-
-namespace YooAsset.Editor
-{
- public static class BuildMapCreater
- {
- ///
- /// 执行资源构建上下文
- ///
- public static BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
- {
- Dictionary buildAssetDic = new Dictionary(1000);
-
- // 1. 检测配置合法性
- AssetBundleCollectorSettingData.Setting.CheckConfigError();
-
- // 2. 获取所有收集器收集的资源
- var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
- List allCollectAssets = buildResult.CollectAssets;
-
- // 3. 剔除未被引用的依赖项资源
- List removeDependList = new List();
- foreach (var collectAssetInfo in allCollectAssets)
- {
- if (collectAssetInfo.CollectorType == ECollectorType.DependAssetCollector)
- {
- if (IsRemoveDependAsset(allCollectAssets, collectAssetInfo.AssetPath))
- removeDependList.Add(collectAssetInfo);
- }
- }
- foreach (var removeValue in removeDependList)
- {
- allCollectAssets.Remove(removeValue);
- }
-
- // 4. 录入所有收集器收集的资源
- foreach (var collectAssetInfo in allCollectAssets)
- {
- if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
- {
- var buildAssetInfo = new BuildAssetInfo(
- collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
- collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
- buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
- buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
- buildAssetDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
- }
- else
- {
- throw new Exception($"Should never get here !");
- }
- }
-
- // 5. 录入所有收集资源的依赖资源
- foreach (var collectAssetInfo in allCollectAssets)
- {
- string collectAssetBundleName = collectAssetInfo.BundleName;
- foreach (var dependAssetPath in collectAssetInfo.DependAssets)
- {
- if (buildAssetDic.ContainsKey(dependAssetPath))
- {
- buildAssetDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
- buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetBundleName);
- }
- else
- {
- var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
- buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
- buildAssetInfo.AddReferenceBundleName(collectAssetBundleName);
- buildAssetDic.Add(dependAssetPath, buildAssetInfo);
- }
- }
- }
-
- // 6. 填充所有收集资源的依赖列表
- foreach (var collectAssetInfo in allCollectAssets)
- {
- var dependAssetInfos = new List(collectAssetInfo.DependAssets.Count);
- foreach (var dependAssetPath in collectAssetInfo.DependAssets)
- {
- if (buildAssetDic.TryGetValue(dependAssetPath, out BuildAssetInfo value))
- dependAssetInfos.Add(value);
- else
- throw new Exception("Should never get here !");
- }
- buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
- }
-
- // 7. 记录关键信息
- BuildMapContext context = new BuildMapContext();
- context.AssetFileCount = buildAssetDic.Count;
- context.EnableAddressable = buildResult.Command.EnableAddressable;
- context.UniqueBundleName = buildResult.Command.UniqueBundleName;
- context.ShadersBundleName = buildResult.ShadersBundleName;
-
- // 8. 计算共享的资源包名
- var command = buildResult.Command;
- foreach (KeyValuePair pair in buildAssetDic)
- {
- pair.Value.CalculateShareBundleName(command.UniqueBundleName, command.PackageName, buildResult.ShadersBundleName);
- }
-
- // 9. 移除不参与构建的资源
- List removeBuildList = new List();
- foreach (KeyValuePair pair in buildAssetDic)
- {
- var buildAssetInfo = pair.Value;
- if (buildAssetInfo.HasBundleName() == false)
- removeBuildList.Add(buildAssetInfo);
- }
- foreach (var removeValue in removeBuildList)
- {
- buildAssetDic.Remove(removeValue.AssetPath);
- }
-
- // 10. 构建资源包
- var allBuildinAssets = buildAssetDic.Values.ToList();
- if (allBuildinAssets.Count == 0)
- throw new Exception("构建的资源列表不能为空");
- foreach (var assetInfo in allBuildinAssets)
- {
- context.PackAsset(assetInfo);
- }
- return context;
- }
- private static bool IsRemoveDependAsset(List allCollectAssets, string dependAssetPath)
- {
- foreach (var collectAssetInfo in allCollectAssets)
- {
- var collectorType = collectAssetInfo.CollectorType;
- if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
- {
- if (collectAssetInfo.DependAssets.Contains(dependAssetPath))
- return false;
- }
- }
-
- BuildLogger.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs.meta
deleted file mode 100644
index 8827383..0000000
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e9274735f1f14af4b893c21a4240b816
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs
index 98dc140..eacf5f5 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
{
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
if (bundleInfo.IsRawFile)
{
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
index ee77076..ea4cae1 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
@@ -119,7 +119,7 @@ namespace YooAsset.Editor
var buildMapContext = context.GetContextObject();
List result = new List(1000);
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
var patchBundle = bundleInfo.CreatePatchBundle();
result.Add(patchBundle);
@@ -135,7 +135,7 @@ namespace YooAsset.Editor
var buildMapContext = context.GetContextObject();
List result = new List(1000);
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
var assetInfos = bundleInfo.GetAllPatchAssetInfos();
foreach (var assetInfo in assetInfos)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs
index efdfe58..54a908e 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs
@@ -67,8 +67,8 @@ namespace YooAsset.Editor
// 拷贝所有补丁文件
int progressValue = 0;
- int patchFileTotalCount = buildMapContext.BundleInfos.Count;
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ int patchFileTotalCount = buildMapContext.Collection.Count;
+ foreach (var bundleInfo in buildMapContext.Collection)
{
EditorTools.CopyFile(bundleInfo.PatchInfo.BuildOutputFilePath, bundleInfo.PatchInfo.PatchOutputFilePath, true);
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
index b8494a6..ab4e64b 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
@@ -35,7 +35,7 @@ namespace YooAsset.Editor
int progressValue = 0;
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
EncryptFileInfo fileInfo = new EncryptFileInfo();
fileInfo.BundleName = bundleInfo.BundleName;
@@ -59,7 +59,7 @@ namespace YooAsset.Editor
}
// 进度条
- EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.BundleInfos.Count);
+ EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.Collection.Count);
}
EditorTools.ClearProgressBar();
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
index fb7112f..7a998a8 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context)
{
var buildParametersContext = context.GetContextObject();
- var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
+ var buildMapContext = CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
context.SetContextObject(buildMapContext);
BuildLogger.Log("构建内容准备完毕!");
@@ -21,12 +21,147 @@ namespace YooAsset.Editor
CheckBuildMapContent(buildMapContext);
}
+ ///
+ /// 资源构建上下文
+ ///
+ public BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
+ {
+ Dictionary buildAssetInfoDic = new Dictionary(1000);
+
+ // 1. 检测配置合法性
+ AssetBundleCollectorSettingData.Setting.CheckConfigError();
+
+ // 2. 获取所有收集器收集的资源
+ var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
+ List collectAssetInfos = collectResult.CollectAssets;
+
+ // 3. 剔除未被引用的依赖项资源
+ List removeDependList = new List();
+ foreach (var collectAssetInfo in collectAssetInfos)
+ {
+ if (collectAssetInfo.CollectorType == ECollectorType.DependAssetCollector)
+ {
+ if (IsRemoveDependAsset(collectAssetInfos, collectAssetInfo.AssetPath))
+ removeDependList.Add(collectAssetInfo);
+ }
+ }
+ foreach (var removeValue in removeDependList)
+ {
+ collectAssetInfos.Remove(removeValue);
+ }
+
+ // 4. 录入所有收集器收集的资源
+ foreach (var collectAssetInfo in collectAssetInfos)
+ {
+ if (buildAssetInfoDic.ContainsKey(collectAssetInfo.AssetPath) == false)
+ {
+ var buildAssetInfo = new BuildAssetInfo(
+ collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
+ collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
+ buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
+ buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
+ buildAssetInfoDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
+ }
+ else
+ {
+ throw new Exception($"Should never get here !");
+ }
+ }
+
+ // 5. 录入所有收集资源的依赖资源
+ foreach (var collectAssetInfo in collectAssetInfos)
+ {
+ string collectAssetBundleName = collectAssetInfo.BundleName;
+ foreach (var dependAssetPath in collectAssetInfo.DependAssets)
+ {
+ if (buildAssetInfoDic.ContainsKey(dependAssetPath))
+ {
+ buildAssetInfoDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
+ buildAssetInfoDic[dependAssetPath].AddReferenceBundleName(collectAssetBundleName);
+ }
+ else
+ {
+ var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
+ buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
+ buildAssetInfo.AddReferenceBundleName(collectAssetBundleName);
+ buildAssetInfoDic.Add(dependAssetPath, buildAssetInfo);
+ }
+ }
+ }
+
+ // 6. 填充所有收集资源的依赖列表
+ foreach (var collectAssetInfo in collectAssetInfos)
+ {
+ var dependAssetInfos = new List(collectAssetInfo.DependAssets.Count);
+ foreach (var dependAssetPath in collectAssetInfo.DependAssets)
+ {
+ if (buildAssetInfoDic.TryGetValue(dependAssetPath, out BuildAssetInfo value))
+ dependAssetInfos.Add(value);
+ else
+ throw new Exception("Should never get here !");
+ }
+ buildAssetInfoDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
+ }
+
+ // 7. 记录关键信息
+ BuildMapContext context = new BuildMapContext();
+ context.AssetFileCount = buildAssetInfoDic.Count;
+ context.EnableAddressable = collectResult.Command.EnableAddressable;
+ context.UniqueBundleName = collectResult.Command.UniqueBundleName;
+ context.ShadersBundleName = collectResult.Command.ShadersBundleName;
+
+ // 8. 计算共享的资源包名
+ var command = collectResult.Command;
+ foreach (KeyValuePair pair in buildAssetInfoDic)
+ {
+ pair.Value.CalculateShareBundleName(command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
+ }
+
+ // 9. 移除不参与构建的资源
+ List removeBuildList = new List();
+ foreach (KeyValuePair pair in buildAssetInfoDic)
+ {
+ var buildAssetInfo = pair.Value;
+ if (buildAssetInfo.HasBundleName() == false)
+ removeBuildList.Add(buildAssetInfo);
+ }
+ foreach (var removeValue in removeBuildList)
+ {
+ buildAssetInfoDic.Remove(removeValue.AssetPath);
+ }
+
+ // 10. 构建资源包
+ var allBuildinAssets = buildAssetInfoDic.Values.ToList();
+ if (allBuildinAssets.Count == 0)
+ throw new Exception("构建的资源列表不能为空");
+ foreach (var assetInfo in allBuildinAssets)
+ {
+ context.PackAsset(assetInfo);
+ }
+ return context;
+ }
+ private bool IsRemoveDependAsset(List allCollectAssets, string dependAssetPath)
+ {
+ foreach (var collectAssetInfo in allCollectAssets)
+ {
+ var collectorType = collectAssetInfo.CollectorType;
+ if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
+ {
+ if (collectAssetInfo.DependAssets.Contains(dependAssetPath))
+ return false;
+ }
+ }
+
+ BuildLogger.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
+ return true;
+ }
+
///
/// 检测构建结果
///
private void CheckBuildMapContent(BuildMapContext buildMapContext)
{
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
// 注意:原生文件资源包只能包含一个原生文件
bool isRawFile = bundleInfo.IsRawFile;
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs
similarity index 93%
rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs
rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs
index 64dca4d..06f8a3d 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs
@@ -6,8 +6,8 @@ using UnityEditor;
namespace YooAsset.Editor
{
- [TaskAttribute("更新构建信息")]
- public class TaskUpdateBuildInfo : IBuildTask
+ [TaskAttribute("更新补丁信息")]
+ public class TaskUpdatePatchInfo : IBuildTask
{
void IBuildTask.Run(BuildContext context)
{
@@ -18,7 +18,7 @@ namespace YooAsset.Editor
int outputNameStyle = (int)buildParametersContext.Parameters.OutputNameStyle;
// 1.检测路径长度
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
// NOTE:检测路径长度不要超过260字符。
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
}
// 2.更新构建输出的文件路径
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
if (bundleInfo.IsEncryptedFile)
bundleInfo.PatchInfo.BuildOutputFilePath = bundleInfo.EncryptedFilePath;
@@ -36,7 +36,7 @@ namespace YooAsset.Editor
}
// 3.更新文件其它信息
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
string buildOutputFilePath = bundleInfo.PatchInfo.BuildOutputFilePath;
bundleInfo.PatchInfo.ContentHash = GetBundleContentHash(bundleInfo, context);
@@ -46,7 +46,7 @@ namespace YooAsset.Editor
}
// 4.更新补丁包输出的文件路径
- foreach (var bundleInfo in buildMapContext.BundleInfos)
+ foreach (var bundleInfo in buildMapContext.Collection)
{
string patchFileExtension = PatchManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName);
string patchFileName = PatchManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, patchFileExtension, bundleInfo.PatchInfo.PatchFileHash);
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs.meta
similarity index 100%
rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBuildInfo.cs.meta
rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs.meta
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
index fc20458..e3ffbbf 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
@@ -37,7 +37,7 @@ namespace YooAsset.Editor
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
// 1. 过滤掉原生Bundle
- string[] mapBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
+ string[] mapBundles = buildMapContext.Collection.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
// 2. 验证Bundle
List exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
index 70e8ad6..b4ec42a 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
@@ -38,7 +38,7 @@ namespace YooAsset.Editor
List unityCreateBundles = buildResults.BundleInfos.Keys.ToList();
// 1. 过滤掉原生Bundle
- List expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
+ List expectBundles = buildMapContext.Collection.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
// 2. 验证Bundle
List exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
index adf6910..8d06f20 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
@@ -217,7 +217,7 @@ namespace YooAsset.Editor
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawFilePackRule)
{
- string address = GetAddress(group, assetPath);
+ string address = GetAddress(command, group, assetPath);
string bundleName = GetBundleName(command, group, assetPath);
List assetTags = GetAssetTags(group);
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, isRawFilePackRule, assetTags);
@@ -280,20 +280,11 @@ namespace YooAsset.Editor
}
string fileExtension = System.IO.Path.GetExtension(assetPath);
- if (IsIgnoreFile(fileExtension))
+ if (DefaultFilterRule.IsIgnoreFile(fileExtension))
return false;
return true;
}
- private bool IsIgnoreFile(string fileExtension)
- {
- foreach (var extension in DefaultFilterRule.IgnoreFileExtensions)
- {
- if (extension == fileExtension)
- return true;
- }
- return false;
- }
private bool IsCollectAsset(string assetPath)
{
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
@@ -304,8 +295,11 @@ namespace YooAsset.Editor
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
}
- private string GetAddress(AssetBundleCollectorGroup group, string assetPath)
+ private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
{
+ if (command.EnableAddressable == false)
+ return string.Empty;
+
if (CollectorType != ECollectorType.MainAssetCollector)
return string.Empty;
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
index 1480c9a..1563147 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
@@ -100,7 +100,7 @@ namespace YooAsset.Editor
{
if (package.PackageName == packageName)
{
- CollectCommand command = new CollectCommand(buildMode, package.PackageName, EnableAddressable, UniqueBundleName);
+ CollectCommand command = new CollectCommand(buildMode, packageName, EnableAddressable, UniqueBundleName);
CollectResult collectResult = new CollectResult(command);
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
return collectResult;
@@ -109,21 +109,5 @@ namespace YooAsset.Editor
throw new Exception($"Not found collector pacakge : {packageName}");
}
-
- ///
- /// 获取所有包裹收集的资源文件
- ///
- public List GetAllPackageAssets(EBuildMode buildMode)
- {
- List collectResultList = new List(1000);
- foreach (var package in Packages)
- {
- CollectCommand command = new CollectCommand(buildMode, package.PackageName, EnableAddressable, UniqueBundleName);
- CollectResult collectResult = new CollectResult(command);
- collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
- collectResultList.Add(collectResult);
- }
- return collectResultList;
- }
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/CollectCommand.cs b/Assets/YooAsset/Editor/AssetBundleCollector/CollectCommand.cs
index 2f6d3bb..c244e1e 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/CollectCommand.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/CollectCommand.cs
@@ -23,12 +23,22 @@ namespace YooAsset.Editor
///
public bool UniqueBundleName { private set; get; }
+ ///
+ /// 着色器统一全名称
+ ///
+ public string ShadersBundleName { private set; get; }
+
+
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool uniqueBundleName)
{
BuildMode = buildMode;
PackageName = packageName;
EnableAddressable = enableAddressable;
UniqueBundleName = uniqueBundleName;
+
+ // 着色器统一全名称
+ var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
+ ShadersBundleName = packRuleResult.GetMainBundleName(packageName, uniqueBundleName);
}
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs b/Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
index 3cbd1cf..1a24cdc 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
@@ -10,26 +10,15 @@ namespace YooAsset.Editor
///
public CollectCommand Command { private set; get; }
- ///
- /// 着色器统一全名称
- ///
- public string ShadersBundleName { private set; get; }
-
///
/// 收集的资源信息列表
///
public List CollectAssets { private set; get; }
-
public CollectResult(CollectCommand command)
{
Command = command;
-
- // 着色器统一全名称
- var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
- ShadersBundleName = packRuleResult.GetMainBundleName(command.PackageName, command.UniqueBundleName);
}
-
public void SetCollectAssets(List collectAssets)
{
CollectAssets = collectAssets;
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs
index b24b0b2..931e00a 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultFilterRule.cs
@@ -1,6 +1,8 @@
-using UnityEngine;
-using UnityEditor;
+using System.Collections;
+using System.Collections.Generic;
using System.IO;
+using UnityEngine;
+using UnityEditor;
namespace YooAsset.Editor
{
@@ -9,7 +11,15 @@ namespace YooAsset.Editor
///
/// 忽略的文件类型
///
- public static readonly string[] IgnoreFileExtensions = { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
+ private readonly static HashSet _ignoreFileExtensions = new HashSet() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
+
+ ///
+ /// 查询是否为忽略文件
+ ///
+ public static bool IsIgnoreFile(string fileExtension)
+ {
+ return _ignoreFileExtensions.Contains(fileExtension);
+ }
}
[DisplayName("收集所有资源")]