diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
index 1eb80f9..3912f94 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
@@ -275,8 +275,7 @@ namespace YooAsset.Editor
buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage;
buildParameters.PackageVersion = _buildVersionField.value;
buildParameters.VerifyBuildingResult = true;
- buildParameters.AutoAnalyzeRedundancy = true;
- buildParameters.SharedPackRule = new DefaultSharedPackRule();
+ buildParameters.SharedPackRule = new ZeroRedundancySharedPackRule();
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
index d75bc5e..4536337 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
@@ -164,7 +164,7 @@ namespace YooAsset.Editor
///
/// 计算共享资源包的完整包名
///
- public void CalculateShareBundleName(ISharedPackRule packRule, bool uniqueBundleName, string packageName, string shadersBundleName)
+ public void CalculateShareBundleName(ISharedPackRule sharedPackRule, bool uniqueBundleName, string packageName, string shadersBundleName)
{
if (CollectorType != ECollectorType.None)
return;
@@ -180,7 +180,7 @@ namespace YooAsset.Editor
{
if (_referenceBundleNames.Count > 1)
{
- PackRuleResult packRuleResult = packRule.GetPackRuleResult(AssetPath);
+ PackRuleResult packRuleResult = sharedPackRule.GetPackRuleResult(AssetPath);
BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
}
else
@@ -196,12 +196,9 @@ namespace YooAsset.Editor
///
public bool IsRedundancyAsset()
{
- if (CollectorType != ECollectorType.None)
+ if (HasBundleName())
return false;
- if (IsRawAsset)
- throw new Exception("Should never get here !");
-
return _referenceBundleNames.Count > 1;
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs
index 4063069..5926547 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs
@@ -49,7 +49,7 @@ namespace YooAsset.Editor
///
/// 参与构建的资源列表
- /// 注意:不包含零依赖资源
+ /// 注意:不包含零依赖资源和冗余资源
///
public readonly List AllMainAssets = new List();
@@ -149,7 +149,15 @@ namespace YooAsset.Editor
}
///
- /// 获取该资源包内的所有资源(包括零依赖资源)
+ /// 获取构建的资源路径列表
+ ///
+ public string[] GetAllMainAssetPaths()
+ {
+ return AllMainAssets.Select(t => t.AssetPath).ToArray();
+ }
+
+ ///
+ /// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
///
public List GetAllBuiltinAssetPaths()
{
@@ -161,6 +169,7 @@ namespace YooAsset.Editor
continue;
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
{
+ // 注意:依赖资源里只添加零依赖资源和冗余资源
if (dependAssetInfo.HasBundleName() == false)
{
if (result.Contains(dependAssetInfo.AssetPath) == false)
@@ -171,22 +180,6 @@ namespace YooAsset.Editor
return result;
}
- ///
- /// 获取构建的资源路径列表
- ///
- public string[] GetAllMainAssetPaths()
- {
- return AllMainAssets.Select(t => t.AssetPath).ToArray();
- }
-
- ///
- /// 获取所有写入补丁清单的资源
- ///
- public BuildAssetInfo[] GetAllMainAssetInfos()
- {
- return AllMainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
- }
-
///
/// 创建AssetBundleBuild类
///
@@ -200,6 +193,14 @@ namespace YooAsset.Editor
return build;
}
+ ///
+ /// 获取所有写入补丁清单的资源
+ ///
+ public BuildAssetInfo[] GetAllManifestAssetInfos()
+ {
+ return AllMainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
+ }
+
///
/// 创建PackageBundle类
///
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs
index 63f43ac..40b6a62 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs
@@ -76,11 +76,6 @@ namespace YooAsset.Editor
/// 验证构建结果
///
public bool VerifyBuildingResult = false;
-
- ///
- /// 自动分析冗余资源
- ///
- public bool AutoAnalyzeRedundancy = true;
///
/// 共享资源的打包规则
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
index 50ba002..f9eb25c 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
@@ -73,11 +73,6 @@ namespace YooAsset.Editor
///
public bool UniqueBundleName;
- ///
- /// 自动分析冗余
- ///
- public bool AutoAnalyzeRedundancy;
-
///
/// 共享资源的打包规则类名
///
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs
index 77581e7..049aac3 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs
@@ -139,7 +139,7 @@ namespace YooAsset.Editor
List result = new List(1000);
foreach (var bundleInfo in buildMapContext.Collection)
{
- var assetInfos = bundleInfo.GetAllMainAssetInfos();
+ var assetInfos = bundleInfo.GetAllManifestAssetInfos();
foreach (var assetInfo in assetInfos)
{
PackageAsset packageAsset = new PackageAsset();
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
index 2a9e3c9..9a86763 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
@@ -49,7 +49,6 @@ namespace YooAsset.Editor
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
- buildReport.Summary.AutoAnalyzeRedundancy = buildParameters.AutoAnalyzeRedundancy;
buildReport.Summary.SharedPackRuleClassName = buildParameters.SharedPackRule == null ?
"null" : buildParameters.SharedPackRule.GetType().FullName;
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
@@ -161,7 +160,7 @@ namespace YooAsset.Editor
}
///
- /// 获取该资源包内的所有资源(包括零依赖资源)
+ /// 获取该资源包内的所有资源
///
private List GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
{
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
index fc558bf..ff93168 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
@@ -29,7 +29,6 @@ namespace YooAsset.Editor
var buildMode = buildParameters.BuildMode;
var packageName = buildParameters.PackageName;
var sharedPackRule = buildParameters.SharedPackRule;
- var autoAnalyzeRedundancy = buildParameters.AutoAnalyzeRedundancy;
Dictionary allBuildAssetInfoDic = new Dictionary(1000);
@@ -100,34 +99,29 @@ namespace YooAsset.Editor
context.AssetFileCount = allBuildAssetInfoDic.Count;
context.Command = collectResult.Command;
- // 8. 计算共享的资源包名
- if (autoAnalyzeRedundancy)
+ // 8. 计算共享资源的包名
+ var command = collectResult.Command;
+ foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
{
- var command = collectResult.Command;
- foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
- {
- buildAssetInfo.CalculateShareBundleName(sharedPackRule, command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
- }
+ buildAssetInfo.CalculateShareBundleName(sharedPackRule, command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
}
- else
+
+ // 9. 记录冗余资源
+ foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
{
- // 记录冗余资源
- foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
+ if (buildAssetInfo.IsRedundancyAsset())
{
- if (buildAssetInfo.IsRedundancyAsset())
- {
- var redundancyInfo = new ReportRedundancyInfo();
- redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
- redundancyInfo.AssetType = AssetDatabase.GetMainAssetTypeAtPath(buildAssetInfo.AssetPath).Name;
- redundancyInfo.AssetGUID = AssetDatabase.AssetPathToGUID(buildAssetInfo.AssetPath);
- redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
- redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
- context.RedundancyInfos.Add(redundancyInfo);
- }
+ var redundancyInfo = new ReportRedundancyInfo();
+ redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
+ redundancyInfo.AssetType = AssetDatabase.GetMainAssetTypeAtPath(buildAssetInfo.AssetPath).Name;
+ redundancyInfo.AssetGUID = AssetDatabase.AssetPathToGUID(buildAssetInfo.AssetPath);
+ redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
+ redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
+ context.RedundancyInfos.Add(redundancyInfo);
}
}
- // 9. 移除不参与构建的资源
+ // 10. 移除不参与构建的资源
List removeBuildList = new List();
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
{
@@ -139,7 +133,7 @@ namespace YooAsset.Editor
allBuildAssetInfoDic.Remove(removeValue.AssetPath);
}
- // 10. 构建资源包
+ // 11. 构建资源列表
var allPackAssets = allBuildAssetInfoDic.Values.ToList();
if (allPackAssets.Count == 0)
throw new Exception("构建的资源列表不能为空");
@@ -147,6 +141,7 @@ namespace YooAsset.Editor
{
context.PackAsset(assetInfo);
}
+
return context;
}
private void RemoveZeroReferenceAssets(List allCollectAssetInfos)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/CollectRules/IPackRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/CollectRules/IPackRule.cs
index 3e45713..feaba34 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/CollectRules/IPackRule.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/CollectRules/IPackRule.cs
@@ -48,12 +48,16 @@ namespace YooAsset.Editor
fullName = $"{bundleName}.{_bundleExtension}";
return fullName.ToLower();
}
-
+
///
/// 获取共享资源包全名称
///
public string GetShareBundleName(string packageName, bool uniqueBundleName)
{
+ // 注意:冗余的共享资源包名返回空
+ if (string.IsNullOrEmpty(_bundleName) && string.IsNullOrEmpty(_bundleExtension))
+ return string.Empty;
+
string fullName;
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
if (uniqueBundleName)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultRules/DefaultSharedPackRule.cs b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultRules/DefaultSharedPackRule.cs
index 6b4b2a4..8dd6987 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/DefaultRules/DefaultSharedPackRule.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/DefaultRules/DefaultSharedPackRule.cs
@@ -5,9 +5,9 @@ using UnityEditor;
namespace YooAsset.Editor
{
///
- /// 零冗余共享资源打包规则
+ /// 零冗余的共享资源打包规则
///
- public class DefaultSharedPackRule : ISharedPackRule
+ public class ZeroRedundancySharedPackRule : ISharedPackRule
{
public PackRuleResult GetPackRuleResult(string assetPath)
{
@@ -16,4 +16,16 @@ namespace YooAsset.Editor
return result;
}
}
+
+ ///
+ /// 全部冗余的共享资源打包规则
+ ///
+ public class FullRedundancySharedPackRule : ISharedPackRule
+ {
+ public PackRuleResult GetPackRuleResult(string assetPath)
+ {
+ PackRuleResult result = new PackRuleResult(string.Empty, string.Empty);
+ return result;
+ }
+ }
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs
index 72b2482..9a2ad93 100644
--- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs
+++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs
@@ -71,7 +71,6 @@ namespace YooAsset.Editor
_items.Add(new ItemWrapper("资源定位地址大小写不敏感", $"{buildReport.Summary.LocationToLower}"));
_items.Add(new ItemWrapper("包含资源GUID数据", $"{buildReport.Summary.IncludeAssetGUID}"));
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
- _items.Add(new ItemWrapper("自动分析冗余资源", $"{buildReport.Summary.AutoAnalyzeRedundancy}"));
_items.Add(new ItemWrapper("共享资源打包规则", buildReport.Summary.SharedPackRuleClassName));
_items.Add(new ItemWrapper("资源加密服务类", buildReport.Summary.EncryptionServicesClassName));