Update AssetBundleBuilder
parent
f0ac319a73
commit
50bfde6e8e
|
@ -20,6 +20,11 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildMode BuildMode = EBuildMode.ForceRebuild;
|
public EBuildMode BuildMode = EBuildMode.ForceRebuild;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建的包裹名称
|
||||||
|
/// </summary>
|
||||||
|
public string BuildPackage = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置资源标签(首包资源标签)
|
/// 内置资源标签(首包资源标签)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace YooAsset.Editor
|
||||||
private BuildTarget _buildTarget;
|
private BuildTarget _buildTarget;
|
||||||
private List<Type> _encryptionServicesClassTypes;
|
private List<Type> _encryptionServicesClassTypes;
|
||||||
private List<string> _encryptionServicesClassNames;
|
private List<string> _encryptionServicesClassNames;
|
||||||
|
private List<string> _buildPackageNames;
|
||||||
|
|
||||||
private Button _saveButton;
|
private Button _saveButton;
|
||||||
private TextField _buildOutputField;
|
private TextField _buildOutputField;
|
||||||
|
@ -28,6 +29,7 @@ namespace YooAsset.Editor
|
||||||
private EnumField _buildPipelineField;
|
private EnumField _buildPipelineField;
|
||||||
private EnumField _buildModeField;
|
private EnumField _buildModeField;
|
||||||
private TextField _buildinTagsField;
|
private TextField _buildinTagsField;
|
||||||
|
private PopupField<string> _buildPackageField;
|
||||||
private PopupField<string> _encryptionField;
|
private PopupField<string> _encryptionField;
|
||||||
private EnumField _compressionField;
|
private EnumField _compressionField;
|
||||||
private EnumField _outputNameStyleField;
|
private EnumField _outputNameStyleField;
|
||||||
|
@ -52,6 +54,9 @@ namespace YooAsset.Editor
|
||||||
// 构建平台
|
// 构建平台
|
||||||
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
_buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
|
|
||||||
|
// 包裹名称列表
|
||||||
|
_buildPackageNames = GetBuildPackageNames();
|
||||||
|
|
||||||
// 加密服务类
|
// 加密服务类
|
||||||
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
|
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
|
||||||
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList();
|
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList();
|
||||||
|
@ -105,11 +110,34 @@ namespace YooAsset.Editor
|
||||||
AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value;
|
AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 构建包裹
|
||||||
|
var buildPackageContainer = root.Q("BuildPackageContainer");
|
||||||
|
if (_buildPackageNames.Count > 0)
|
||||||
|
{
|
||||||
|
int defaultIndex = GetDefaultPackageIndex(AssetBundleBuilderSettingData.Setting.BuildPackage);
|
||||||
|
_buildPackageField = new PopupField<string>(_buildPackageNames, defaultIndex);
|
||||||
|
_buildPackageField.label = "Build Package";
|
||||||
|
_buildPackageField.style.width = 350;
|
||||||
|
_buildPackageField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
|
AssetBundleBuilderSettingData.Setting.BuildPackage = _buildPackageField.value;
|
||||||
|
});
|
||||||
|
buildPackageContainer.Add(_buildPackageField);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_buildPackageField = new PopupField<string>();
|
||||||
|
_buildPackageField.label = "Build Package";
|
||||||
|
_buildPackageField.style.width = 350;
|
||||||
|
buildPackageContainer.Add(_buildPackageField);
|
||||||
|
}
|
||||||
|
|
||||||
// 加密方法
|
// 加密方法
|
||||||
var encryptionContainer = root.Q("EncryptionContainer");
|
var encryptionContainer = root.Q("EncryptionContainer");
|
||||||
if (_encryptionServicesClassNames.Count > 0)
|
if (_encryptionServicesClassNames.Count > 0)
|
||||||
{
|
{
|
||||||
int defaultIndex = GetEncryptionDefaultIndex(AssetBundleBuilderSettingData.Setting.EncyptionClassName);
|
int defaultIndex = GetDefaultEncryptionIndex(AssetBundleBuilderSettingData.Setting.EncyptionClassName);
|
||||||
_encryptionField = new PopupField<string>(_encryptionServicesClassNames, defaultIndex);
|
_encryptionField = new PopupField<string>(_encryptionServicesClassNames, defaultIndex);
|
||||||
_encryptionField.label = "Encryption";
|
_encryptionField.label = "Encryption";
|
||||||
_encryptionField.style.width = 350;
|
_encryptionField.style.width = 350;
|
||||||
|
@ -163,21 +191,21 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
if(AssetBundleBuilderSettingData.IsDirty)
|
if (AssetBundleBuilderSettingData.IsDirty)
|
||||||
AssetBundleBuilderSettingData.SaveFile();
|
AssetBundleBuilderSettingData.SaveFile();
|
||||||
}
|
}
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if(_saveButton != null)
|
if (_saveButton != null)
|
||||||
{
|
{
|
||||||
if(AssetBundleBuilderSettingData.IsDirty)
|
if (AssetBundleBuilderSettingData.IsDirty)
|
||||||
{
|
{
|
||||||
if (_saveButton.enabledSelf == false)
|
if (_saveButton.enabledSelf == false)
|
||||||
_saveButton.SetEnabled(true);
|
_saveButton.SetEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(_saveButton.enabledSelf)
|
if (_saveButton.enabledSelf)
|
||||||
_saveButton.SetEnabled(false);
|
_saveButton.SetEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,6 +250,7 @@ namespace YooAsset.Editor
|
||||||
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
||||||
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||||
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
||||||
|
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||||
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||||
|
@ -244,8 +273,33 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 构建包裹相关
|
||||||
|
private int GetDefaultPackageIndex(string packageName)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < _buildPackageNames.Count; index++)
|
||||||
|
{
|
||||||
|
if (_buildPackageNames[index] == packageName)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
|
AssetBundleBuilderSettingData.Setting.BuildPackage = _buildPackageNames[0];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
private List<string> GetBuildPackageNames()
|
||||||
|
{
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||||
|
{
|
||||||
|
result.Add(package.PackageName);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// 加密类相关
|
// 加密类相关
|
||||||
private int GetEncryptionDefaultIndex(string className)
|
private int GetDefaultEncryptionIndex(string className)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < _encryptionServicesClassNames.Count; index++)
|
for (int index = 0; index < _encryptionServicesClassNames.Count; index++)
|
||||||
{
|
{
|
||||||
|
@ -254,6 +308,9 @@ namespace YooAsset.Editor
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AssetBundleBuilderSettingData.IsDirty = true;
|
||||||
|
AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionServicesClassNames[0];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
private List<Type> GetEncryptionServicesClassTypes()
|
private List<Type> GetEncryptionServicesClassTypes()
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
|
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
|
||||||
<uie:EnumField label="Build Pipeline" name="BuildPipeline" />
|
<uie:EnumField label="Build Pipeline" name="BuildPipeline" />
|
||||||
<uie:EnumField label="Build Mode" name="BuildMode" />
|
<uie:EnumField label="Build Mode" name="BuildMode" />
|
||||||
|
<ui:VisualElement name="BuildPackageContainer" style="height: 24px;" />
|
||||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||||
<uie:EnumField label="Output Name Style" value="Center" name="OutputNameStyle" />
|
<uie:EnumField label="Output Name Style" value="Center" name="OutputNameStyle" />
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace YooAsset.Editor
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.BuildVersion = 999;
|
buildParameters.BuildVersion = 999;
|
||||||
|
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行资源构建上下文
|
/// 执行资源构建上下文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static BuildMapContext CreateBuildMap(EBuildMode buildMode)
|
public static BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
|
||||||
{
|
{
|
||||||
BuildMapContext context = new BuildMapContext();
|
BuildMapContext context = new BuildMapContext();
|
||||||
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
||||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||||
|
|
||||||
// 2. 获取所有收集器收集的资源
|
// 2. 获取所有收集器收集的资源
|
||||||
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(buildMode);
|
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||||
|
|
||||||
// 3. 剔除未被引用的依赖资源
|
// 3. 剔除未被引用的依赖资源
|
||||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||||
|
|
|
@ -56,6 +56,11 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildMode BuildMode;
|
public EBuildMode BuildMode;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建的Package名称
|
||||||
|
/// </summary>
|
||||||
|
public string BuildPackage;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的版本(资源版本号)
|
/// 构建的版本(资源版本号)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode);
|
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.BuildPackage);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
BuildRunner.Log("构建内容准备完毕!");
|
BuildRunner.Log("构建内容准备完毕!");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue