mirror of https://github.com/tuyoogame/YooAsset
Update AssetBundleBuilder
parent
3689a39a47
commit
7bd09080ef
|
@ -8,94 +8,6 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleBuilder
|
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
|
public class BuildParametersContext : IContextObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -139,15 +51,15 @@ namespace YooAsset.Editor
|
||||||
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
||||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||||
|
|
||||||
if (Parameters.IsForceRebuild)
|
if (Parameters.ForceRebuild)
|
||||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||||
if (Parameters.IsAppendHash)
|
if (Parameters.AppendHash)
|
||||||
opt |= BuildAssetBundleOptions.AppendHashToAssetBundleName; //Append the hash to the assetBundle name
|
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).
|
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.
|
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.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.
|
||||||
|
@ -157,7 +69,6 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private readonly BuildContext _buildContext = new BuildContext();
|
private readonly BuildContext _buildContext = new BuildContext();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -28,8 +28,8 @@ namespace YooAsset.Editor
|
||||||
private int _buildVersion;
|
private int _buildVersion;
|
||||||
private BuildTarget _buildTarget;
|
private BuildTarget _buildTarget;
|
||||||
private ECompressOption _compressOption = ECompressOption.Uncompressed;
|
private ECompressOption _compressOption = ECompressOption.Uncompressed;
|
||||||
private bool _isAppendExtension = false;
|
private bool _appendExtension = false;
|
||||||
private bool _isForceRebuild = false;
|
private bool _forceRebuild = false;
|
||||||
private string _buildinTags = string.Empty;
|
private string _buildinTags = string.Empty;
|
||||||
|
|
||||||
// GUI相关
|
// GUI相关
|
||||||
|
@ -54,9 +54,9 @@ namespace YooAsset.Editor
|
||||||
// 构建参数
|
// 构建参数
|
||||||
_buildVersion = EditorGUILayout.IntField("Build Version", _buildVersion, GUILayout.MaxWidth(250));
|
_buildVersion = EditorGUILayout.IntField("Build Version", _buildVersion, GUILayout.MaxWidth(250));
|
||||||
_compressOption = (ECompressOption)EditorGUILayout.EnumPopup("Compression", _compressOption, GUILayout.MaxWidth(250));
|
_compressOption = (ECompressOption)EditorGUILayout.EnumPopup("Compression", _compressOption, GUILayout.MaxWidth(250));
|
||||||
_isAppendExtension = GUILayout.Toggle(_isAppendExtension, "Append Extension", GUILayout.MaxWidth(120));
|
_appendExtension = GUILayout.Toggle(_appendExtension, "Append Extension", GUILayout.MaxWidth(120));
|
||||||
_isForceRebuild = GUILayout.Toggle(_isForceRebuild, "Force Rebuild", GUILayout.MaxWidth(120));
|
_forceRebuild = GUILayout.Toggle(_forceRebuild, "Force Rebuild", GUILayout.MaxWidth(120));
|
||||||
if (_isForceRebuild)
|
if (_forceRebuild)
|
||||||
_buildinTags = EditorGUILayout.TextField("Buildin Tags", _buildinTags);
|
_buildinTags = EditorGUILayout.TextField("Buildin Tags", _buildinTags);
|
||||||
|
|
||||||
// 构建按钮
|
// 构建按钮
|
||||||
|
@ -65,7 +65,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
string title;
|
string title;
|
||||||
string content;
|
string content;
|
||||||
if (_isForceRebuild)
|
if (_forceRebuild)
|
||||||
{
|
{
|
||||||
title = "警告";
|
title = "警告";
|
||||||
content = "确定开始强制构建吗,这样会删除所有已有构建的文件";
|
content = "确定开始强制构建吗,这样会删除所有已有构建的文件";
|
||||||
|
@ -114,22 +114,22 @@ namespace YooAsset.Editor
|
||||||
private void ExecuteBuild()
|
private void ExecuteBuild()
|
||||||
{
|
{
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||||
AssetBundleBuilder.BuildParameters buildParameters = new AssetBundleBuilder.BuildParameters();
|
BuildParameters buildParameters = new BuildParameters();
|
||||||
buildParameters.IsVerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.OutputRoot = defaultOutputRoot;
|
buildParameters.OutputRoot = defaultOutputRoot;
|
||||||
buildParameters.BuildTarget = _buildTarget;
|
buildParameters.BuildTarget = _buildTarget;
|
||||||
buildParameters.BuildVersion = _buildVersion;
|
buildParameters.BuildVersion = _buildVersion;
|
||||||
buildParameters.CompressOption = _compressOption;
|
buildParameters.CompressOption = _compressOption;
|
||||||
buildParameters.AppendFileExtension = _isAppendExtension;
|
buildParameters.AppendFileExtension = _appendExtension;
|
||||||
buildParameters.IsForceRebuild = _isForceRebuild;
|
buildParameters.ForceRebuild = _forceRebuild;
|
||||||
buildParameters.BuildinTags = _buildinTags;
|
buildParameters.BuildinTags = _buildinTags;
|
||||||
_assetBuilder.Run(buildParameters);
|
_assetBuilder.Run(buildParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 配置相关
|
#region 配置相关
|
||||||
private const string StrEditorCompressOption = "StrEditorCompressOption";
|
private const string StrEditorCompressOption = "StrEditorCompressOption";
|
||||||
private const string StrEditorIsAppendExtension = "StrEditorIsAppendExtension";
|
private const string StrEditorAppendExtension = "StrEditorAppendExtension";
|
||||||
private const string StrEditorIsForceRebuild = "StrEditorIsForceRebuild";
|
private const string StrEditorForceRebuild = "StrEditorForceRebuild";
|
||||||
private const string StrEditorBuildinTags = "StrEditorBuildinTags";
|
private const string StrEditorBuildinTags = "StrEditorBuildinTags";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -138,8 +138,8 @@ namespace YooAsset.Editor
|
||||||
private void SaveSettingsToPlayerPrefs()
|
private void SaveSettingsToPlayerPrefs()
|
||||||
{
|
{
|
||||||
EditorTools.PlayerSetEnum<ECompressOption>(StrEditorCompressOption, _compressOption);
|
EditorTools.PlayerSetEnum<ECompressOption>(StrEditorCompressOption, _compressOption);
|
||||||
EditorPrefs.SetBool(StrEditorIsAppendExtension, _isAppendExtension);
|
EditorPrefs.SetBool(StrEditorAppendExtension, _appendExtension);
|
||||||
EditorPrefs.SetBool(StrEditorIsForceRebuild, _isForceRebuild);
|
EditorPrefs.SetBool(StrEditorForceRebuild, _forceRebuild);
|
||||||
EditorPrefs.SetString(StrEditorBuildinTags, _buildinTags);
|
EditorPrefs.SetString(StrEditorBuildinTags, _buildinTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,8 +149,8 @@ namespace YooAsset.Editor
|
||||||
private void LoadSettingsFromPlayerPrefs()
|
private void LoadSettingsFromPlayerPrefs()
|
||||||
{
|
{
|
||||||
_compressOption = EditorTools.PlayerGetEnum<ECompressOption>(StrEditorCompressOption, ECompressOption.Uncompressed);
|
_compressOption = EditorTools.PlayerGetEnum<ECompressOption>(StrEditorCompressOption, ECompressOption.Uncompressed);
|
||||||
_isAppendExtension = EditorPrefs.GetBool(StrEditorIsAppendExtension, false);
|
_appendExtension = EditorPrefs.GetBool(StrEditorAppendExtension, false);
|
||||||
_isForceRebuild = EditorPrefs.GetBool(StrEditorIsForceRebuild, false);
|
_forceRebuild = EditorPrefs.GetBool(StrEditorForceRebuild, false);
|
||||||
_buildinTags = EditorPrefs.GetString(StrEditorBuildinTags, string.Empty);
|
_buildinTags = EditorPrefs.GetString(StrEditorBuildinTags, string.Empty);
|
||||||
}
|
}
|
||||||
#endregion
|
#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
|
public class BuildReport
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建汇总信息
|
/// 汇总信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildSummary Summary = new BuildSummary();
|
public ReportSummary Summary = new ReportSummary();
|
||||||
|
|
||||||
/// <summary>
|
/// <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);
|
VerifyingBuildingResult(context, unityManifest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
// 注意:我们只有在强制重建的时候才会拷贝
|
// 注意:我们只有在强制重建的时候才会拷贝
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
if(buildParameters.Parameters.IsForceRebuild)
|
if(buildParameters.Parameters.ForceRebuild)
|
||||||
{
|
{
|
||||||
// 清空流目录
|
// 清空流目录
|
||||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 加载旧补丁清单
|
// 加载旧补丁清单
|
||||||
PatchManifest oldPatchManifest = null;
|
PatchManifest oldPatchManifest = null;
|
||||||
if (buildParameters.Parameters.IsForceRebuild == false)
|
if (buildParameters.Parameters.ForceRebuild == false)
|
||||||
{
|
{
|
||||||
oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
|
oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ namespace YooAsset.Editor
|
||||||
AppendData(content, $"构建时间:{DateTime.Now}");
|
AppendData(content, $"构建时间:{DateTime.Now}");
|
||||||
AppendData(content, $"构建平台:{buildParameters.Parameters.BuildTarget}");
|
AppendData(content, $"构建平台:{buildParameters.Parameters.BuildTarget}");
|
||||||
AppendData(content, $"构建版本:{buildParameters.Parameters.BuildVersion}");
|
AppendData(content, $"构建版本:{buildParameters.Parameters.BuildVersion}");
|
||||||
AppendData(content, $"冗余机制:{buildParameters.Parameters.ApplyRedundancy}");
|
AppendData(content, $"自动分包:{buildParameters.Parameters.EnableAutoCollect}");
|
||||||
|
|
||||||
AppendData(content, "");
|
AppendData(content, "");
|
||||||
AppendData(content, $"--着色器--");
|
AppendData(content, $"--着色器--");
|
||||||
AppendData(content, $"IsCollectAllShaders:{AssetBundleCollectorSettingData.Setting.IsCollectAllShaders}");
|
AppendData(content, $"IsCollectAllShaders:{AssetBundleCollectorSettingData.Setting.AutoCollectShaders}");
|
||||||
AppendData(content, $"ShadersBundleName:{AssetBundleCollectorSettingData.Setting.ShadersBundleName}");
|
AppendData(content, $"ShadersBundleName:{AssetBundleCollectorSettingData.Setting.ShadersBundleName}");
|
||||||
|
|
||||||
AppendData(content, "");
|
AppendData(content, "");
|
||||||
|
@ -54,12 +54,12 @@ namespace YooAsset.Editor
|
||||||
AppendData(content, "");
|
AppendData(content, "");
|
||||||
AppendData(content, $"--构建参数--");
|
AppendData(content, $"--构建参数--");
|
||||||
AppendData(content, $"CompressOption:{buildParameters.Parameters.CompressOption}");
|
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, $"BuildinTags:{buildParameters.Parameters.BuildinTags}");
|
||||||
AppendData(content, $"IsAppendHash:{buildParameters.Parameters.IsAppendHash}");
|
AppendData(content, $"IsAppendHash:{buildParameters.Parameters.AppendHash}");
|
||||||
AppendData(content, $"IsDisableWriteTypeTree:{buildParameters.Parameters.IsDisableWriteTypeTree}");
|
AppendData(content, $"IsDisableWriteTypeTree:{buildParameters.Parameters.DisableWriteTypeTree}");
|
||||||
AppendData(content, $"IsIgnoreTypeTreeChanges:{buildParameters.Parameters.IsIgnoreTypeTreeChanges}");
|
AppendData(content, $"IsIgnoreTypeTreeChanges:{buildParameters.Parameters.IgnoreTypeTreeChanges}");
|
||||||
AppendData(content, $"IsDisableLoadAssetByFileName : {buildParameters.Parameters.IsDisableLoadAssetByFileName}");
|
AppendData(content, $"IsDisableLoadAssetByFileName : {buildParameters.Parameters.DisableLoadAssetByFileName}");
|
||||||
|
|
||||||
AppendData(content, "");
|
AppendData(content, "");
|
||||||
AppendData(content, $"--构建信息--");
|
AppendData(content, $"--构建信息--");
|
||||||
|
|
|
@ -22,22 +22,37 @@ namespace YooAsset.Editor
|
||||||
BuildReport buildReport = new BuildReport();
|
BuildReport buildReport = new BuildReport();
|
||||||
|
|
||||||
// 概述信息
|
// 概述信息
|
||||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
{
|
||||||
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||||
buildReport.Summary.BuildSeconds = 0;
|
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
||||||
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
buildReport.Summary.BuildSeconds = 0;
|
||||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
||||||
buildReport.Summary.ApplyRedundancy = buildParameters.Parameters.ApplyRedundancy;
|
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
|
||||||
buildReport.Summary.IsCollectAllShaders = AssetBundleCollectorSettingData.Setting.IsCollectAllShaders;
|
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||||
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
|
||||||
buildReport.Summary.IsForceRebuild = buildParameters.Parameters.IsForceRebuild;
|
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
|
||||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
// 构建参数
|
||||||
buildReport.Summary.IsAppendHash = buildParameters.Parameters.IsAppendHash;
|
buildReport.Summary.ForceRebuild = buildParameters.Parameters.ForceRebuild;
|
||||||
buildReport.Summary.IsDisableWriteTypeTree = buildParameters.Parameters.IsDisableWriteTypeTree;
|
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||||
buildReport.Summary.IsIgnoreTypeTreeChanges = buildParameters.Parameters.IsIgnoreTypeTreeChanges;
|
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||||
buildReport.Summary.IsDisableLoadAssetByFileName = buildParameters.Parameters.IsDisableLoadAssetByFileName;
|
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);
|
buildReport.AssetInfos = new List<ReportAssetInfo>(patchManifest.AssetList.Count);
|
||||||
|
@ -85,7 +100,7 @@ namespace YooAsset.Editor
|
||||||
private List<string> GetDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
private List<string> GetDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
||||||
{
|
{
|
||||||
List<string> dependBundles = new List<string>(patchAsset.DependIDs.Length);
|
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;
|
string dependBundleName = patchManifest.BundleList[index].BundleName;
|
||||||
dependBundles.Add(dependBundleName);
|
dependBundles.Add(dependBundleName);
|
||||||
|
@ -99,12 +114,12 @@ namespace YooAsset.Editor
|
||||||
private List<string> GetDependAssets(TaskGetBuildMap.BuildMapContext buildMapContext, string bundleName, string assetPath)
|
private List<string> GetDependAssets(TaskGetBuildMap.BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
if(buildMapContext.TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
if (buildMapContext.TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||||
{
|
{
|
||||||
BuildAssetInfo findAssetInfo = null;
|
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;
|
findAssetInfo = buildinAsset;
|
||||||
break;
|
break;
|
||||||
|
@ -114,7 +129,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
throw new Exception($"Not found asset {assetPath} in bunlde {bundleName}");
|
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);
|
result.Add(dependAssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
|
@ -125,5 +140,79 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return result;
|
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
|
public class BuildMapContext : IContextObject
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 参与构建的资源总数
|
||||||
|
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||||
|
/// </summary>
|
||||||
|
public int AssetFileCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包列表
|
/// 资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -179,7 +185,10 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
// 3. 移除零依赖的资源
|
// 3. 记录参与构建的资源总数
|
||||||
|
buildMapContext.AssetFileCount = buildAssetDic.Values.Count;
|
||||||
|
|
||||||
|
// 4. 移除零依赖的资源
|
||||||
var redundancy = CreateAssetRedundancy();
|
var redundancy = CreateAssetRedundancy();
|
||||||
List<BuildAssetInfo> undependentAssets = new List<BuildAssetInfo>();
|
List<BuildAssetInfo> undependentAssets = new List<BuildAssetInfo>();
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
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);
|
||||||
undependentAssets.Add(buildAssetInfo);
|
continue;
|
||||||
buildMapContext.RedundancyAssetList.Add(buildAssetInfo.AssetPath);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 冗余机制
|
// 如果没有开启自动分包,没有被收集到的资源会造成冗余
|
||||||
if (buildParameters.Parameters.ApplyRedundancy)
|
if (buildParameters.Parameters.EnableAutoCollect == false)
|
||||||
{
|
{
|
||||||
if (AssetBundleCollectorSettingData.HasCollector(buildAssetInfo.AssetPath) == false)
|
if (AssetBundleCollectorSettingData.HasCollector(buildAssetInfo.AssetPath) == false)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +227,7 @@ namespace YooAsset.Editor
|
||||||
buildAssetDic.Remove(assetInfo.AssetPath);
|
buildAssetDic.Remove(assetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 设置资源包名
|
// 5. 设置资源包名
|
||||||
progressValue = 0;
|
progressValue = 0;
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +241,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
// 4. 构建资源包
|
// 6. 构建资源包
|
||||||
var allAssets = buildAssetDic.Values.ToList();
|
var allAssets = buildAssetDic.Values.ToList();
|
||||||
if (allAssets.Count == 0)
|
if (allAssets.Count == 0)
|
||||||
throw new Exception("构建的资源列表不能为空");
|
throw new Exception("构建的资源列表不能为空");
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace YooAsset.Editor
|
||||||
throw new Exception("配置的资源收集路径为空");
|
throw new Exception("配置的资源收集路径为空");
|
||||||
|
|
||||||
// 增量更新时候的必要检测
|
// 增量更新时候的必要检测
|
||||||
if (buildParameters.Parameters.IsForceRebuild == false)
|
if (buildParameters.Parameters.ForceRebuild == false)
|
||||||
{
|
{
|
||||||
// 检测历史版本是否存在
|
// 检测历史版本是否存在
|
||||||
if (AssetBundleBuilderHelper.HasAnyPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot) == 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}";
|
string platformDirectory = $"{buildParameters.Parameters.OutputRoot}/{buildParameters.Parameters.BuildTarget}";
|
||||||
|
|
Loading…
Reference in New Issue