Update AssetBundleBuilder
parent
3689a39a47
commit
7bd09080ef
|
@ -8,94 +8,6 @@ namespace YooAsset.Editor
|
|||
{
|
||||
public class AssetBundleBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否验证构建结果
|
||||
/// </summary>
|
||||
public bool IsVerifyBuildingResult = false;
|
||||
|
||||
/// <summary>
|
||||
/// 输出的根目录
|
||||
/// </summary>
|
||||
public string OutputRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的版本(资源版本号)
|
||||
/// </summary>
|
||||
public int BuildVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 是否允许冗余机制
|
||||
/// 说明:冗余机制可以帮助我们减少包体数量
|
||||
/// </summary>
|
||||
public bool ApplyRedundancy = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否附加上文件扩展名
|
||||
/// </summary>
|
||||
public bool AppendFileExtension = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption;
|
||||
|
||||
/// <summary>
|
||||
/// 是否强制重新构建整个项目,如果为FALSE则是增量打包
|
||||
/// </summary>
|
||||
public bool IsForceRebuild;
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源的标记列表
|
||||
/// 注意:分号为分隔符
|
||||
/// </summary>
|
||||
public string BuildinTags;
|
||||
|
||||
#region 高级选项
|
||||
/// <summary>
|
||||
/// 文件名附加上哈希值
|
||||
/// </summary>
|
||||
public bool IsAppendHash = false;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool IsDisableWriteTypeTree = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// </summary>
|
||||
public bool IsIgnoreTypeTreeChanges = true;
|
||||
|
||||
/// <summary>
|
||||
/// 禁用名称查找资源(可以降内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool IsDisableLoadAssetByFileName = false;
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置标记列表
|
||||
/// </summary>
|
||||
public List<string> GetBuildinTags()
|
||||
{
|
||||
return StringUtility.StringToStringList(BuildinTags, ';');
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建参数环境
|
||||
/// </summary>
|
||||
public class BuildParametersContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -139,15 +51,15 @@ namespace YooAsset.Editor
|
|||
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||
|
||||
if (Parameters.IsForceRebuild)
|
||||
if (Parameters.ForceRebuild)
|
||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||
if (Parameters.IsAppendHash)
|
||||
if (Parameters.AppendHash)
|
||||
opt |= BuildAssetBundleOptions.AppendHashToAssetBundleName; //Append the hash to the assetBundle name
|
||||
if (Parameters.IsDisableWriteTypeTree)
|
||||
if (Parameters.DisableWriteTypeTree)
|
||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||
if (Parameters.IsIgnoreTypeTreeChanges)
|
||||
if (Parameters.IgnoreTypeTreeChanges)
|
||||
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
||||
if (Parameters.IsDisableLoadAssetByFileName)
|
||||
if (Parameters.DisableLoadAssetByFileName)
|
||||
{
|
||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
||||
|
@ -157,7 +69,6 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private readonly BuildContext _buildContext = new BuildContext();
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -28,8 +28,8 @@ namespace YooAsset.Editor
|
|||
private int _buildVersion;
|
||||
private BuildTarget _buildTarget;
|
||||
private ECompressOption _compressOption = ECompressOption.Uncompressed;
|
||||
private bool _isAppendExtension = false;
|
||||
private bool _isForceRebuild = false;
|
||||
private bool _appendExtension = false;
|
||||
private bool _forceRebuild = false;
|
||||
private string _buildinTags = string.Empty;
|
||||
|
||||
// GUI相关
|
||||
|
@ -54,9 +54,9 @@ namespace YooAsset.Editor
|
|||
// 构建参数
|
||||
_buildVersion = EditorGUILayout.IntField("Build Version", _buildVersion, GUILayout.MaxWidth(250));
|
||||
_compressOption = (ECompressOption)EditorGUILayout.EnumPopup("Compression", _compressOption, GUILayout.MaxWidth(250));
|
||||
_isAppendExtension = GUILayout.Toggle(_isAppendExtension, "Append Extension", GUILayout.MaxWidth(120));
|
||||
_isForceRebuild = GUILayout.Toggle(_isForceRebuild, "Force Rebuild", GUILayout.MaxWidth(120));
|
||||
if (_isForceRebuild)
|
||||
_appendExtension = GUILayout.Toggle(_appendExtension, "Append Extension", GUILayout.MaxWidth(120));
|
||||
_forceRebuild = GUILayout.Toggle(_forceRebuild, "Force Rebuild", GUILayout.MaxWidth(120));
|
||||
if (_forceRebuild)
|
||||
_buildinTags = EditorGUILayout.TextField("Buildin Tags", _buildinTags);
|
||||
|
||||
// 构建按钮
|
||||
|
@ -65,7 +65,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
string title;
|
||||
string content;
|
||||
if (_isForceRebuild)
|
||||
if (_forceRebuild)
|
||||
{
|
||||
title = "警告";
|
||||
content = "确定开始强制构建吗,这样会删除所有已有构建的文件";
|
||||
|
@ -114,22 +114,22 @@ namespace YooAsset.Editor
|
|||
private void ExecuteBuild()
|
||||
{
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
AssetBundleBuilder.BuildParameters buildParameters = new AssetBundleBuilder.BuildParameters();
|
||||
buildParameters.IsVerifyBuildingResult = true;
|
||||
BuildParameters buildParameters = new BuildParameters();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = _buildTarget;
|
||||
buildParameters.BuildVersion = _buildVersion;
|
||||
buildParameters.CompressOption = _compressOption;
|
||||
buildParameters.AppendFileExtension = _isAppendExtension;
|
||||
buildParameters.IsForceRebuild = _isForceRebuild;
|
||||
buildParameters.AppendFileExtension = _appendExtension;
|
||||
buildParameters.ForceRebuild = _forceRebuild;
|
||||
buildParameters.BuildinTags = _buildinTags;
|
||||
_assetBuilder.Run(buildParameters);
|
||||
}
|
||||
|
||||
#region 配置相关
|
||||
private const string StrEditorCompressOption = "StrEditorCompressOption";
|
||||
private const string StrEditorIsAppendExtension = "StrEditorIsAppendExtension";
|
||||
private const string StrEditorIsForceRebuild = "StrEditorIsForceRebuild";
|
||||
private const string StrEditorAppendExtension = "StrEditorAppendExtension";
|
||||
private const string StrEditorForceRebuild = "StrEditorForceRebuild";
|
||||
private const string StrEditorBuildinTags = "StrEditorBuildinTags";
|
||||
|
||||
/// <summary>
|
||||
|
@ -138,8 +138,8 @@ namespace YooAsset.Editor
|
|||
private void SaveSettingsToPlayerPrefs()
|
||||
{
|
||||
EditorTools.PlayerSetEnum<ECompressOption>(StrEditorCompressOption, _compressOption);
|
||||
EditorPrefs.SetBool(StrEditorIsAppendExtension, _isAppendExtension);
|
||||
EditorPrefs.SetBool(StrEditorIsForceRebuild, _isForceRebuild);
|
||||
EditorPrefs.SetBool(StrEditorAppendExtension, _appendExtension);
|
||||
EditorPrefs.SetBool(StrEditorForceRebuild, _forceRebuild);
|
||||
EditorPrefs.SetString(StrEditorBuildinTags, _buildinTags);
|
||||
}
|
||||
|
||||
|
@ -149,8 +149,8 @@ namespace YooAsset.Editor
|
|||
private void LoadSettingsFromPlayerPrefs()
|
||||
{
|
||||
_compressOption = EditorTools.PlayerGetEnum<ECompressOption>(StrEditorCompressOption, ECompressOption.Uncompressed);
|
||||
_isAppendExtension = EditorPrefs.GetBool(StrEditorIsAppendExtension, false);
|
||||
_isForceRebuild = EditorPrefs.GetBool(StrEditorIsForceRebuild, false);
|
||||
_appendExtension = EditorPrefs.GetBool(StrEditorAppendExtension, false);
|
||||
_forceRebuild = EditorPrefs.GetBool(StrEditorForceRebuild, false);
|
||||
_buildinTags = EditorPrefs.GetString(StrEditorBuildinTags, string.Empty);
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
public bool VerifyBuildingResult = false;
|
||||
|
||||
/// <summary>
|
||||
/// 输出的根目录
|
||||
/// </summary>
|
||||
public string OutputRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的版本(资源版本号)
|
||||
/// </summary>
|
||||
public int BuildVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 启用自动分包机制
|
||||
/// 说明:自动分包机制可以实现资源零冗余
|
||||
/// </summary>
|
||||
public bool EnableAutoCollect = true;
|
||||
|
||||
/// <summary>
|
||||
/// 追加文件扩展名
|
||||
/// </summary>
|
||||
public bool AppendFileExtension = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 强制重新构建整个项目,如果为FALSE则是增量打包
|
||||
/// </summary>
|
||||
public bool ForceRebuild;
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源的标记列表
|
||||
/// 注意:分号为分隔符
|
||||
/// </summary>
|
||||
public string BuildinTags;
|
||||
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名附加上哈希值
|
||||
/// </summary>
|
||||
public bool AppendHash = false;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
/// <summary>
|
||||
/// 禁用名称查找资源(可以降内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableLoadAssetByFileName = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置标记列表
|
||||
/// </summary>
|
||||
public List<string> GetBuildinTags()
|
||||
{
|
||||
return StringUtility.StringToStringList(BuildinTags, ';');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 98bb314dc26ba184fbb9e9fdcdb58a1d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -12,9 +12,9 @@ namespace YooAsset.Editor
|
|||
public class BuildReport
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建汇总信息
|
||||
/// 汇总信息
|
||||
/// </summary>
|
||||
public BuildSummary Summary = new BuildSummary();
|
||||
public ReportSummary Summary = new ReportSummary();
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象列表
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class BuildSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// 引擎版本
|
||||
/// </summary>
|
||||
public string UnityVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 构建时间
|
||||
/// </summary>
|
||||
public string BuildTime;
|
||||
|
||||
/// <summary>
|
||||
/// 构建耗时(单位:秒)
|
||||
/// </summary>
|
||||
public int BuildSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// 构建平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建版本
|
||||
/// </summary>
|
||||
public int BuildVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启冗余机制
|
||||
/// </summary>
|
||||
public bool ApplyRedundancy;
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启文件后缀名
|
||||
/// </summary>
|
||||
public bool AppendFileExtension;
|
||||
|
||||
#region 着色器
|
||||
public bool IsCollectAllShaders;
|
||||
public string ShadersBundleName;
|
||||
#endregion
|
||||
|
||||
#region 构建参数
|
||||
public bool IsForceRebuild;
|
||||
public string BuildinTags;
|
||||
public ECompressOption CompressOption;
|
||||
public bool IsAppendHash;
|
||||
public bool IsDisableWriteTypeTree;
|
||||
public bool IsIgnoreTypeTreeChanges;
|
||||
public bool IsDisableLoadAssetByFileName;
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// 引擎版本
|
||||
/// </summary>
|
||||
public string UnityVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 构建时间
|
||||
/// </summary>
|
||||
public string BuildTime;
|
||||
|
||||
/// <summary>
|
||||
/// 构建耗时(单位:秒)
|
||||
/// </summary>
|
||||
public int BuildSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// 构建平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建版本
|
||||
/// </summary>
|
||||
public int BuildVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 启用自动分包机制
|
||||
/// </summary>
|
||||
public bool EnableAutoCollect;
|
||||
|
||||
/// <summary>
|
||||
/// 追加文件扩展名
|
||||
/// </summary>
|
||||
public bool AppendFileExtension;
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集着色器
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders;
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集的着色器资源包名
|
||||
/// </summary>
|
||||
public string ShadersBundleName;
|
||||
|
||||
// 构建参数
|
||||
public bool ForceRebuild;
|
||||
public string BuildinTags;
|
||||
public ECompressOption CompressOption;
|
||||
public bool AppendHash;
|
||||
public bool DisableWriteTypeTree;
|
||||
public bool IgnoreTypeTreeChanges;
|
||||
public bool DisableLoadAssetByFileName;
|
||||
|
||||
// 构建结果
|
||||
public int AssetFileTotalCount;
|
||||
public int AllBundleTotalCount;
|
||||
public long AllBundleTotalSize;
|
||||
public int BuildinBundleTotalCount;
|
||||
public long BuildinBundleTotalSize;
|
||||
public int EncryptedBundleTotalCount;
|
||||
public long EncryptedBundleTotalSize;
|
||||
public int RawBundleTotalCount;
|
||||
public long RawBundleTotalSize;
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 验证构建结果
|
||||
if (buildParametersContext.Parameters.IsVerifyBuildingResult)
|
||||
if (buildParametersContext.Parameters.VerifyBuildingResult)
|
||||
{
|
||||
VerifyingBuildingResult(context, unityManifest);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
// 注意:我们只有在强制重建的时候才会拷贝
|
||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||
if(buildParameters.Parameters.IsForceRebuild)
|
||||
if(buildParameters.Parameters.ForceRebuild)
|
||||
{
|
||||
// 清空流目录
|
||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace YooAsset.Editor
|
|||
|
||||
// 加载旧补丁清单
|
||||
PatchManifest oldPatchManifest = null;
|
||||
if (buildParameters.Parameters.IsForceRebuild == false)
|
||||
if (buildParameters.Parameters.ForceRebuild == false)
|
||||
{
|
||||
oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
|
||||
}
|
||||
|
|
|
@ -36,11 +36,11 @@ namespace YooAsset.Editor
|
|||
AppendData(content, $"构建时间:{DateTime.Now}");
|
||||
AppendData(content, $"构建平台:{buildParameters.Parameters.BuildTarget}");
|
||||
AppendData(content, $"构建版本:{buildParameters.Parameters.BuildVersion}");
|
||||
AppendData(content, $"冗余机制:{buildParameters.Parameters.ApplyRedundancy}");
|
||||
AppendData(content, $"自动分包:{buildParameters.Parameters.EnableAutoCollect}");
|
||||
|
||||
AppendData(content, "");
|
||||
AppendData(content, $"--着色器--");
|
||||
AppendData(content, $"IsCollectAllShaders:{AssetBundleCollectorSettingData.Setting.IsCollectAllShaders}");
|
||||
AppendData(content, $"IsCollectAllShaders:{AssetBundleCollectorSettingData.Setting.AutoCollectShaders}");
|
||||
AppendData(content, $"ShadersBundleName:{AssetBundleCollectorSettingData.Setting.ShadersBundleName}");
|
||||
|
||||
AppendData(content, "");
|
||||
|
@ -54,12 +54,12 @@ namespace YooAsset.Editor
|
|||
AppendData(content, "");
|
||||
AppendData(content, $"--构建参数--");
|
||||
AppendData(content, $"CompressOption:{buildParameters.Parameters.CompressOption}");
|
||||
AppendData(content, $"IsForceRebuild:{buildParameters.Parameters.IsForceRebuild}");
|
||||
AppendData(content, $"IsForceRebuild:{buildParameters.Parameters.ForceRebuild}");
|
||||
AppendData(content, $"BuildinTags:{buildParameters.Parameters.BuildinTags}");
|
||||
AppendData(content, $"IsAppendHash:{buildParameters.Parameters.IsAppendHash}");
|
||||
AppendData(content, $"IsDisableWriteTypeTree:{buildParameters.Parameters.IsDisableWriteTypeTree}");
|
||||
AppendData(content, $"IsIgnoreTypeTreeChanges:{buildParameters.Parameters.IsIgnoreTypeTreeChanges}");
|
||||
AppendData(content, $"IsDisableLoadAssetByFileName : {buildParameters.Parameters.IsDisableLoadAssetByFileName}");
|
||||
AppendData(content, $"IsAppendHash:{buildParameters.Parameters.AppendHash}");
|
||||
AppendData(content, $"IsDisableWriteTypeTree:{buildParameters.Parameters.DisableWriteTypeTree}");
|
||||
AppendData(content, $"IsIgnoreTypeTreeChanges:{buildParameters.Parameters.IgnoreTypeTreeChanges}");
|
||||
AppendData(content, $"IsDisableLoadAssetByFileName : {buildParameters.Parameters.DisableLoadAssetByFileName}");
|
||||
|
||||
AppendData(content, "");
|
||||
AppendData(content, $"--构建信息--");
|
||||
|
|
|
@ -22,22 +22,37 @@ namespace YooAsset.Editor
|
|||
BuildReport buildReport = new BuildReport();
|
||||
|
||||
// 概述信息
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = 0;
|
||||
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||
buildReport.Summary.ApplyRedundancy = buildParameters.Parameters.ApplyRedundancy;
|
||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||
buildReport.Summary.IsCollectAllShaders = AssetBundleCollectorSettingData.Setting.IsCollectAllShaders;
|
||||
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||
buildReport.Summary.IsForceRebuild = buildParameters.Parameters.IsForceRebuild;
|
||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||
buildReport.Summary.IsAppendHash = buildParameters.Parameters.IsAppendHash;
|
||||
buildReport.Summary.IsDisableWriteTypeTree = buildParameters.Parameters.IsDisableWriteTypeTree;
|
||||
buildReport.Summary.IsIgnoreTypeTreeChanges = buildParameters.Parameters.IsIgnoreTypeTreeChanges;
|
||||
buildReport.Summary.IsDisableLoadAssetByFileName = buildParameters.Parameters.IsDisableLoadAssetByFileName;
|
||||
{
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = 0;
|
||||
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||
buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
|
||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
|
||||
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||
|
||||
// 构建参数
|
||||
buildReport.Summary.ForceRebuild = buildParameters.Parameters.ForceRebuild;
|
||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||
buildReport.Summary.AppendHash = buildParameters.Parameters.AppendHash;
|
||||
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges;
|
||||
buildReport.Summary.DisableLoadAssetByFileName = buildParameters.Parameters.DisableLoadAssetByFileName;
|
||||
|
||||
// 构建结果
|
||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(patchManifest);
|
||||
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(patchManifest);
|
||||
buildReport.Summary.BuildinBundleTotalCount = GetBuildinBundleCount(patchManifest);
|
||||
buildReport.Summary.BuildinBundleTotalSize = GetBuildinBundleSize(patchManifest);
|
||||
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(patchManifest);
|
||||
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(patchManifest);
|
||||
buildReport.Summary.RawBundleTotalCount = GetRawBundleCount(patchManifest);
|
||||
buildReport.Summary.RawBundleTotalSize = GetRawBundleSize(patchManifest);
|
||||
}
|
||||
|
||||
// 资源对象列表
|
||||
buildReport.AssetInfos = new List<ReportAssetInfo>(patchManifest.AssetList.Count);
|
||||
|
@ -85,7 +100,7 @@ namespace YooAsset.Editor
|
|||
private List<string> GetDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(patchAsset.DependIDs.Length);
|
||||
foreach(int index in patchAsset.DependIDs)
|
||||
foreach (int index in patchAsset.DependIDs)
|
||||
{
|
||||
string dependBundleName = patchManifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
|
@ -99,12 +114,12 @@ namespace YooAsset.Editor
|
|||
private List<string> GetDependAssets(TaskGetBuildMap.BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
if(buildMapContext.TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||
if (buildMapContext.TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
BuildAssetInfo findAssetInfo = null;
|
||||
foreach(var buildinAsset in bundleInfo.BuildinAssets)
|
||||
foreach (var buildinAsset in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if(buildinAsset.AssetPath == assetPath)
|
||||
if (buildinAsset.AssetPath == assetPath)
|
||||
{
|
||||
findAssetInfo = buildinAsset;
|
||||
break;
|
||||
|
@ -114,7 +129,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
throw new Exception($"Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach(var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetPath);
|
||||
}
|
||||
|
@ -125,5 +140,79 @@ namespace YooAsset.Editor
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int GetAllBundleCount(PatchManifest patchManifest)
|
||||
{
|
||||
return patchManifest.BundleList.Count;
|
||||
}
|
||||
private long GetAllBundleSize(PatchManifest patchManifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
fileBytes += patchBundle.SizeBytes;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetBuildinBundleCount(PatchManifest patchManifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsBuildin)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetBuildinBundleSize(PatchManifest patchManifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsBuildin)
|
||||
fileBytes += patchBundle.SizeBytes;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetEncryptedBundleCount(PatchManifest patchManifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsEncrypted)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetEncryptedBundleSize(PatchManifest patchManifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsEncrypted)
|
||||
fileBytes += patchBundle.SizeBytes;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetRawBundleCount(PatchManifest patchManifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsRawFile)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetRawBundleSize(PatchManifest patchManifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.IsRawFile)
|
||||
fileBytes += patchBundle.SizeBytes;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,12 @@ namespace YooAsset.Editor
|
|||
{
|
||||
public class BuildMapContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 参与构建的资源总数
|
||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||
/// </summary>
|
||||
public int AssetFileCount;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包列表
|
||||
/// </summary>
|
||||
|
@ -179,7 +185,10 @@ namespace YooAsset.Editor
|
|||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
|
||||
// 3. 移除零依赖的资源
|
||||
// 3. 记录参与构建的资源总数
|
||||
buildMapContext.AssetFileCount = buildAssetDic.Values.Count;
|
||||
|
||||
// 4. 移除零依赖的资源
|
||||
var redundancy = CreateAssetRedundancy();
|
||||
List<BuildAssetInfo> undependentAssets = new List<BuildAssetInfo>();
|
||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||
|
@ -196,18 +205,15 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 冗余扩展
|
||||
if(redundancy != null)
|
||||
if (redundancy != null && redundancy.Check(buildAssetInfo.AssetPath))
|
||||
{
|
||||
if(redundancy.Check(buildAssetInfo.AssetPath))
|
||||
{
|
||||
undependentAssets.Add(buildAssetInfo);
|
||||
buildMapContext.RedundancyAssetList.Add(buildAssetInfo.AssetPath);
|
||||
continue;
|
||||
}
|
||||
undependentAssets.Add(buildAssetInfo);
|
||||
buildMapContext.RedundancyAssetList.Add(buildAssetInfo.AssetPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 冗余机制
|
||||
if (buildParameters.Parameters.ApplyRedundancy)
|
||||
// 如果没有开启自动分包,没有被收集到的资源会造成冗余
|
||||
if (buildParameters.Parameters.EnableAutoCollect == false)
|
||||
{
|
||||
if (AssetBundleCollectorSettingData.HasCollector(buildAssetInfo.AssetPath) == false)
|
||||
{
|
||||
|
@ -221,7 +227,7 @@ namespace YooAsset.Editor
|
|||
buildAssetDic.Remove(assetInfo.AssetPath);
|
||||
}
|
||||
|
||||
// 4. 设置资源包名
|
||||
// 5. 设置资源包名
|
||||
progressValue = 0;
|
||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||
{
|
||||
|
@ -235,7 +241,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
|
||||
// 4. 构建资源包
|
||||
// 6. 构建资源包
|
||||
var allAssets = buildAssetDic.Values.ToList();
|
||||
if (allAssets.Count == 0)
|
||||
throw new Exception("构建的资源列表不能为空");
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace YooAsset.Editor
|
|||
throw new Exception("配置的资源收集路径为空");
|
||||
|
||||
// 增量更新时候的必要检测
|
||||
if (buildParameters.Parameters.IsForceRebuild == false)
|
||||
if (buildParameters.Parameters.ForceRebuild == false)
|
||||
{
|
||||
// 检测历史版本是否存在
|
||||
if (AssetBundleBuilderHelper.HasAnyPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot) == false)
|
||||
|
@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 如果是强制重建
|
||||
if (buildParameters.Parameters.IsForceRebuild)
|
||||
if (buildParameters.Parameters.ForceRebuild)
|
||||
{
|
||||
// 删除平台总目录
|
||||
string platformDirectory = $"{buildParameters.Parameters.OutputRoot}/{buildParameters.Parameters.BuildTarget}";
|
||||
|
|
Loading…
Reference in New Issue