mirror of https://github.com/tuyoogame/YooAsset
Optimize assetbundle build parameters
优化了资源包的构建参数:始终开启DisableLoadAssetByFileNamepull/13/head
parent
029b850d6b
commit
a054740de6
|
@ -54,9 +54,7 @@ namespace YooAsset.Editor
|
||||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||||
|
|
||||||
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
|
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
}
|
|
||||||
|
|
||||||
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
|
@ -71,17 +69,13 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
|
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||||
if (Parameters.AppendHash)
|
|
||||||
opt |= BuildAssetBundleOptions.AppendHashToAssetBundleName; //Append the hash to the assetBundle name
|
|
||||||
if (Parameters.DisableWriteTypeTree)
|
if (Parameters.DisableWriteTypeTree)
|
||||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||||
if (Parameters.IgnoreTypeTreeChanges)
|
if (Parameters.IgnoreTypeTreeChanges)
|
||||||
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
||||||
if (Parameters.DisableLoadAssetByFileName)
|
|
||||||
{
|
|
||||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
||||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
||||||
}
|
|
||||||
|
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable = false;
|
public bool EnableAddressable = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 启用自动分包机制
|
|
||||||
/// 说明:自动分包机制可以实现资源零冗余
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableAutoCollect = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 追加文件扩展名
|
/// 追加文件扩展名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -68,11 +62,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件名附加上哈希值
|
|
||||||
/// </summary>
|
|
||||||
public bool AppendHash = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -83,11 +72,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreTypeTreeChanges = true;
|
public bool IgnoreTypeTreeChanges = true;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 禁用名称查找资源(可以降内存并提高加载效率)
|
|
||||||
/// </summary>
|
|
||||||
public bool DisableLoadAssetByFileName = false;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置标记列表
|
/// 获取内置标记列表
|
||||||
|
|
|
@ -48,11 +48,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 启用自动分包机制
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableAutoCollect;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 追加文件扩展名
|
/// 追加文件扩展名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -75,10 +70,8 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
public ECompressOption CompressOption;
|
public ECompressOption CompressOption;
|
||||||
public bool AppendHash;
|
|
||||||
public bool DisableWriteTypeTree;
|
public bool DisableWriteTypeTree;
|
||||||
public bool IgnoreTypeTreeChanges;
|
public bool IgnoreTypeTreeChanges;
|
||||||
public bool DisableLoadAssetByFileName;
|
|
||||||
|
|
||||||
// 构建结果
|
// 构建结果
|
||||||
public int AssetFileTotalCount;
|
public int AssetFileTotalCount;
|
||||||
|
|
|
@ -41,7 +41,6 @@ namespace YooAsset.Editor
|
||||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||||
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
||||||
buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
|
|
||||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||||
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
|
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
|
||||||
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||||
|
@ -50,10 +49,8 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||||
buildReport.Summary.AppendHash = buildParameters.Parameters.AppendHash;
|
|
||||||
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
|
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges;
|
buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges;
|
||||||
buildReport.Summary.DisableLoadAssetByFileName = buildParameters.Parameters.DisableLoadAssetByFileName;
|
|
||||||
|
|
||||||
// 构建结果
|
// 构建结果
|
||||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||||
|
|
|
@ -71,7 +71,6 @@ namespace YooAsset.Editor
|
||||||
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
|
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
||||||
_items.Add(new ItemWrapper("启用自动分包机制", $"{buildReport.Summary.EnableAutoCollect}"));
|
|
||||||
_items.Add(new ItemWrapper("追加文件扩展名", $"{buildReport.Summary.AppendFileExtension}"));
|
_items.Add(new ItemWrapper("追加文件扩展名", $"{buildReport.Summary.AppendFileExtension}"));
|
||||||
_items.Add(new ItemWrapper("自动收集着色器", $"{buildReport.Summary.AutoCollectShaders}"));
|
_items.Add(new ItemWrapper("自动收集着色器", $"{buildReport.Summary.AutoCollectShaders}"));
|
||||||
_items.Add(new ItemWrapper("着色器资源包名称", $"{buildReport.Summary.ShadersBundleName}"));
|
_items.Add(new ItemWrapper("着色器资源包名称", $"{buildReport.Summary.ShadersBundleName}"));
|
||||||
|
@ -80,10 +79,8 @@ namespace YooAsset.Editor
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
_items.Add(new ItemWrapper("构建参数", string.Empty));
|
_items.Add(new ItemWrapper("构建参数", string.Empty));
|
||||||
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
||||||
_items.Add(new ItemWrapper("AppendHash", $"{buildReport.Summary.AppendHash}"));
|
|
||||||
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
|
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
|
||||||
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"));
|
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"));
|
||||||
_items.Add(new ItemWrapper("DisableLoadAssetByFileName", $"{buildReport.Summary.DisableLoadAssetByFileName}"));
|
|
||||||
|
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
_items.Add(new ItemWrapper("构建结果", string.Empty));
|
_items.Add(new ItemWrapper("构建结果", string.Empty));
|
||||||
|
|
|
@ -69,16 +69,16 @@ namespace YooAsset
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetName);
|
AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetPath);
|
||||||
else
|
else
|
||||||
AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetName, MainAssetInfo.AssetType);
|
AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetName);
|
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath);
|
||||||
else
|
else
|
||||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetName, MainAssetInfo.AssetType);
|
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||||
}
|
}
|
||||||
Status = EStatus.Checking;
|
Status = EStatus.Checking;
|
||||||
}
|
}
|
||||||
|
@ -106,9 +106,9 @@ namespace YooAsset
|
||||||
if (Status == EStatus.Fail)
|
if (Status == EStatus.Fail)
|
||||||
{
|
{
|
||||||
if(MainAssetInfo.AssetType == null)
|
if(MainAssetInfo.AssetType == null)
|
||||||
LastError = $"Failed to load asset : {MainAssetInfo.AssetName} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
|
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
|
||||||
else
|
else
|
||||||
LastError = $"Failed to load asset : {MainAssetInfo.AssetName} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
|
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(LastError);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
|
|
|
@ -69,16 +69,16 @@ namespace YooAsset
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetName);
|
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetPath);
|
||||||
else
|
else
|
||||||
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetName, MainAssetInfo.AssetType);
|
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetName);
|
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath);
|
||||||
else
|
else
|
||||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetName, MainAssetInfo.AssetType);
|
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||||
}
|
}
|
||||||
Status = EStatus.Checking;
|
Status = EStatus.Checking;
|
||||||
}
|
}
|
||||||
|
@ -106,9 +106,9 @@ namespace YooAsset
|
||||||
if (Status == EStatus.Fail)
|
if (Status == EStatus.Fail)
|
||||||
{
|
{
|
||||||
if (MainAssetInfo.AssetType == null)
|
if (MainAssetInfo.AssetType == null)
|
||||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetName} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
|
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
|
||||||
else
|
else
|
||||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetName} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
|
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(LastError);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
|
|
|
@ -41,11 +41,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal string Error { private set; get; }
|
internal string Error { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源对象名称
|
|
||||||
/// </summary>
|
|
||||||
public string AssetName { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -69,7 +64,6 @@ namespace YooAsset
|
||||||
_patchAsset = patchAsset;
|
_patchAsset = patchAsset;
|
||||||
AssetType = assetType;
|
AssetType = assetType;
|
||||||
AssetPath = patchAsset.AssetPath;
|
AssetPath = patchAsset.AssetPath;
|
||||||
AssetName = Path.GetFileName(patchAsset.AssetPath);
|
|
||||||
Error = string.Empty;
|
Error = string.Empty;
|
||||||
}
|
}
|
||||||
internal AssetInfo(PatchAsset patchAsset)
|
internal AssetInfo(PatchAsset patchAsset)
|
||||||
|
@ -80,7 +74,6 @@ namespace YooAsset
|
||||||
_patchAsset = patchAsset;
|
_patchAsset = patchAsset;
|
||||||
AssetType = null;
|
AssetType = null;
|
||||||
AssetPath = patchAsset.AssetPath;
|
AssetPath = patchAsset.AssetPath;
|
||||||
AssetName = Path.GetFileName(patchAsset.AssetPath);
|
|
||||||
Error = string.Empty;
|
Error = string.Empty;
|
||||||
}
|
}
|
||||||
internal AssetInfo(string error)
|
internal AssetInfo(string error)
|
||||||
|
@ -88,7 +81,6 @@ namespace YooAsset
|
||||||
_patchAsset = null;
|
_patchAsset = null;
|
||||||
AssetType = null;
|
AssetType = null;
|
||||||
AssetPath = string.Empty;
|
AssetPath = string.Empty;
|
||||||
AssetName = string.Empty;
|
|
||||||
Error = error;
|
Error = error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue