diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
index dd23547..1882945 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
@@ -257,7 +257,6 @@ namespace YooAsset.Editor
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
buildParameters.VerifyBuildingResult = true;
- buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs
index 6b1d784..1ffb531 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs
@@ -15,7 +15,6 @@ namespace YooAsset.Editor
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
buildParameters.BuildMode = EBuildMode.SimulateBuild;
buildParameters.BuildPackage = packageName;
- buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
AssetBundleBuilder builder = new AssetBundleBuilder();
var buildResult = builder.Run(buildParameters);
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
index 308b1e1..ec364a4 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
@@ -166,7 +166,7 @@ namespace YooAsset.Editor
///
/// 计算主资源或共享资源的完整包名
///
- public void CalculateFullBundleName()
+ public void CalculateFullBundleName(bool uniqueBundleName, string packageName)
{
if (CollectorType == ECollectorType.None)
{
@@ -177,15 +177,22 @@ namespace YooAsset.Editor
{
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
- return;
+ }
+ else
+ {
+ if (_referenceBundleNames.Count > 1)
+ {
+ IPackRule packRule = PackDirectory.StaticPackRule;
+ var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
+ var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
+ _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
+ }
}
- if (_referenceBundleNames.Count > 1)
+ if (uniqueBundleName)
{
- IPackRule packRule = PackDirectory.StaticPackRule;
- var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
- var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
- _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
+ if (string.IsNullOrEmpty(_shareBundleName) == false)
+ _shareBundleName = $"{packageName.ToLower()}_{_shareBundleName}";
}
}
else
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
index ceab13f..c92f020 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs
@@ -14,6 +14,16 @@ namespace YooAsset.Editor
///
public int AssetFileCount;
+ ///
+ /// 是否启用可寻址资源定位
+ ///
+ public bool EnableAddressable;
+
+ ///
+ /// 资源包名唯一化
+ ///
+ public bool UniqueBundleName;
+
///
/// 资源包列表
///
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs
index 0624bd1..bf783d3 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapCreater.cs
@@ -19,7 +19,8 @@ namespace YooAsset.Editor
AssetBundleCollectorSettingData.Setting.CheckConfigError();
// 2. 获取所有收集器收集的资源
- List allCollectAssets = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
+ var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
+ List allCollectAssets = buildResult.CollectAssets;
// 3. 剔除未被引用的依赖资源
List removeDependList = new List();
@@ -72,9 +73,13 @@ namespace YooAsset.Editor
}
}
}
- context.AssetFileCount = buildAssetDic.Count;
- // 6. 填充主动收集资源的依赖列表
+ // 6. 记录关键信息
+ context.AssetFileCount = buildAssetDic.Count;
+ context.EnableAddressable = buildResult.EnableAddressable;
+ context.UniqueBundleName = buildResult.UniqueBundleName;
+
+ // 7. 填充主动收集资源的依赖列表
foreach (var collectAssetInfo in allCollectAssets)
{
var dependAssetInfos = new List(collectAssetInfo.DependAssets.Count);
@@ -88,13 +93,13 @@ namespace YooAsset.Editor
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
}
- // 7. 计算完整的资源包名
+ // 8. 计算完整的资源包名
foreach (KeyValuePair pair in buildAssetDic)
{
- pair.Value.CalculateFullBundleName();
+ pair.Value.CalculateFullBundleName(buildResult.UniqueBundleName, buildResult.PackageName);
}
- // 8. 移除不参与构建的资源
+ // 9. 移除不参与构建的资源
List removeBuildList = new List();
foreach (KeyValuePair pair in buildAssetDic)
{
@@ -107,7 +112,7 @@ namespace YooAsset.Editor
buildAssetDic.Remove(removeValue.AssetPath);
}
- // 9. 构建资源包
+ // 10. 构建资源包
var allBuildinAssets = buildAssetDic.Values.ToList();
if (allBuildinAssets.Count == 0)
throw new Exception("构建的资源列表不能为空");
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs
index ccd7c7f..ad79097 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs
@@ -71,12 +71,7 @@ namespace YooAsset.Editor
/// 验证构建结果
///
public bool VerifyBuildingResult = false;
-
- ///
- /// 启用可寻址资源定位
- ///
- public bool EnableAddressable = false;
-
+
///
/// 加密类
///
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
index 65c4733..babdfa9 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
@@ -53,6 +53,11 @@ namespace YooAsset.Editor
///
public bool EnableAddressable;
+ ///
+ /// 资源包名唯一化
+ ///
+ public bool UniqueBundleName;
+
///
/// 加密服务类名称
///
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
index c3b6a49..5bba327 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
@@ -21,6 +21,7 @@ namespace YooAsset.Editor
///
private void CreatePatchManifestFile(BuildContext context)
{
+ var buildMapContext = context.GetContextObject();
var buildParametersContext = context.GetContextObject();
var buildParameters = buildParametersContext.Parameters;
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
@@ -28,7 +29,7 @@ namespace YooAsset.Editor
// 创建新补丁清单
PatchManifest patchManifest = new PatchManifest();
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
- patchManifest.EnableAddressable = buildParameters.EnableAddressable;
+ patchManifest.EnableAddressable = buildMapContext.EnableAddressable;
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
patchManifest.PackageName = buildParameters.BuildPackage;
patchManifest.HumanReadableVersion = buildParameters.HumanReadableVersion;
@@ -125,7 +126,6 @@ namespace YooAsset.Editor
///
private List GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
{
- var buildParameters = context.GetContextObject();
var buildMapContext = context.GetContextObject();
List result = new List(1000);
@@ -135,7 +135,7 @@ namespace YooAsset.Editor
foreach (var assetInfo in assetInfos)
{
PatchAsset patchAsset = new PatchAsset();
- if (buildParameters.Parameters.EnableAddressable)
+ if (buildMapContext.EnableAddressable)
patchAsset.Address = assetInfo.Address;
else
patchAsset.Address = string.Empty;
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
index 2ab0cc0..4a1eb3e 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
@@ -46,7 +46,9 @@ namespace YooAsset.Editor
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
buildReport.Summary.BuildMode = buildParameters.BuildMode;
buildReport.Summary.BuildPackage = buildParameters.BuildPackage;
- buildReport.Summary.EnableAddressable = buildParameters.EnableAddressable;
+ buildReport.Summary.EnableAddressable = buildMapContext.EnableAddressable;
+ buildReport.Summary.UniqueBundleName = buildMapContext.UniqueBundleName;
+
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
"null" : buildParameters.EncryptionServices.GetType().FullName;