mirror of https://github.com/tuyoogame/YooAsset
parent
8d02406211
commit
665a16fe60
|
@ -28,8 +28,10 @@ namespace YooAsset.Editor
|
||||||
Parameters = parameters;
|
Parameters = parameters;
|
||||||
|
|
||||||
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
||||||
if (parameters.DryRunBuild)
|
if (parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
PipelineOutputDirectory += "_DryRunBuild";
|
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
|
||||||
|
else if(parameters.BuildMode == EBuildMode.FastRunBuild)
|
||||||
|
PipelineOutputDirectory += $"_{EBuildMode.FastRunBuild}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -51,7 +53,12 @@ namespace YooAsset.Editor
|
||||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||||
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.DryRunBuild)
|
if (Parameters.BuildMode == EBuildMode.FastRunBuild)
|
||||||
|
{
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
opt |= BuildAssetBundleOptions.DryRunBuild;
|
||||||
return opt;
|
return opt;
|
||||||
|
@ -62,7 +69,7 @@ namespace YooAsset.Editor
|
||||||
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
||||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||||
|
|
||||||
if (Parameters.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)
|
if (Parameters.AppendHash)
|
||||||
opt |= BuildAssetBundleOptions.AppendHashToAssetBundleName; //Append the hash to the assetBundle name
|
opt |= BuildAssetBundleOptions.AppendHashToAssetBundleName; //Append the hash to the assetBundle name
|
||||||
|
@ -125,11 +132,16 @@ namespace YooAsset.Editor
|
||||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (buildParameters.BuildMode == EBuildMode.FastRunBuild)
|
||||||
|
BuildRunner.EnableLog = false;
|
||||||
|
else
|
||||||
|
BuildRunner.EnableLog = true;
|
||||||
|
|
||||||
bool succeed = BuildRunner.Run(pipeline, _buildContext);
|
bool succeed = BuildRunner.Run(pipeline, _buildContext);
|
||||||
if (succeed)
|
if (succeed)
|
||||||
Debug.Log($"构建成功!");
|
Debug.Log($"{buildParameters.BuildMode}模式构建成功!");
|
||||||
else
|
else
|
||||||
Debug.LogWarning($"构建失败!");
|
Debug.LogWarning($"{buildParameters.BuildMode}模式构建失败!");
|
||||||
return succeed;
|
return succeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,16 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int BuildVersion = 0;
|
public int BuildVersion = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建模式
|
||||||
|
/// </summary>
|
||||||
|
public EBuildMode BuildMode = EBuildMode.ForceRebuild;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置资源标签
|
||||||
|
/// </summary>
|
||||||
|
public string BuildTags = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 压缩方式
|
/// 压缩方式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -24,20 +34,5 @@ namespace YooAsset.Editor
|
||||||
/// 附加后缀格式
|
/// 附加后缀格式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AppendExtension = false;
|
public bool AppendExtension = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 强制构建
|
|
||||||
/// </summary>
|
|
||||||
public bool ForceRebuild = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 演练构建
|
|
||||||
/// </summary>
|
|
||||||
public bool DryRunBuild = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 内置标签
|
|
||||||
/// </summary>
|
|
||||||
public string BuildTags = string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,15 +22,13 @@ namespace YooAsset.Editor
|
||||||
private List<Type> _encryptionServicesClassTypes;
|
private List<Type> _encryptionServicesClassTypes;
|
||||||
private List<string> _encryptionServicesClassNames;
|
private List<string> _encryptionServicesClassNames;
|
||||||
|
|
||||||
private TextField _buildOutputTxt;
|
private TextField _buildOutputField;
|
||||||
private IntegerField _buildVersionField;
|
private IntegerField _buildVersionField;
|
||||||
private EnumField _compressionField;
|
private EnumField _buildModeField;
|
||||||
|
private TextField _buildTagsField;
|
||||||
private PopupField<string> _encryptionField;
|
private PopupField<string> _encryptionField;
|
||||||
|
private EnumField _compressionField;
|
||||||
private Toggle _appendExtensionToggle;
|
private Toggle _appendExtensionToggle;
|
||||||
private Toggle _forceRebuildToggle;
|
|
||||||
private Toggle _dryRunBuildToggle;
|
|
||||||
private TextField _buildTagsTxt;
|
|
||||||
|
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
|
@ -56,9 +54,9 @@ namespace YooAsset.Editor
|
||||||
// 输出目录
|
// 输出目录
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(defaultOutputRoot, _buildTarget);
|
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(defaultOutputRoot, _buildTarget);
|
||||||
_buildOutputTxt = root.Q<TextField>("BuildOutput");
|
_buildOutputField = root.Q<TextField>("BuildOutput");
|
||||||
_buildOutputTxt.SetValueWithoutNotify(pipelineOutputDirectory);
|
_buildOutputField.SetValueWithoutNotify(pipelineOutputDirectory);
|
||||||
_buildOutputTxt.SetEnabled(false);
|
_buildOutputField.SetEnabled(false);
|
||||||
|
|
||||||
// 构建版本
|
// 构建版本
|
||||||
_buildVersionField = root.Q<IntegerField>("BuildVersion");
|
_buildVersionField = root.Q<IntegerField>("BuildVersion");
|
||||||
|
@ -68,34 +66,33 @@ namespace YooAsset.Editor
|
||||||
AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value;
|
AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 压缩方式
|
// 构建模式
|
||||||
_compressionField = root.Q<EnumField>("Compression");
|
_buildModeField = root.Q<EnumField>("BuildMode");
|
||||||
_compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
|
_buildModeField.Init(AssetBundleBuilderSettingData.Setting.BuildMode);
|
||||||
_compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
|
_buildModeField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildMode);
|
||||||
_compressionField.style.width = 300;
|
_buildModeField.style.width = 300;
|
||||||
_compressionField.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
|
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||||
_compressionField.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
{
|
||||||
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
|
AssetBundleBuilderSettingData.Setting.BuildMode = (EBuildMode)_buildModeField.value;
|
||||||
|
RefreshWindow();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 内置资源标签
|
||||||
|
_buildTagsField = root.Q<TextField>("BuildinTags");
|
||||||
|
_buildTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
|
||||||
|
_buildTagsField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleBuilderSettingData.Setting.BuildTags = _buildTagsField.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 加密方法
|
// 加密方法
|
||||||
var encryptionContainer = root.Q("EncryptionContainer");
|
var encryptionContainer = root.Q("EncryptionContainer");
|
||||||
if (_encryptionServicesClassNames.Count > 0)
|
if (_encryptionServicesClassNames.Count > 0)
|
||||||
{
|
{
|
||||||
int defaultIndex = 0;
|
int defaultIndex = GetEncryptionDefaultIndex(AssetBundleBuilderSettingData.Setting.EncyptionClassName);
|
||||||
for (int index = 0; index < _encryptionServicesClassNames.Count; index++)
|
|
||||||
{
|
|
||||||
if (_encryptionServicesClassNames[index] == AssetBundleBuilderSettingData.Setting.EncyptionClassName)
|
|
||||||
{
|
|
||||||
defaultIndex = index;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_encryptionField = new PopupField<string>(_encryptionServicesClassNames, defaultIndex);
|
_encryptionField = new PopupField<string>(_encryptionServicesClassNames, defaultIndex);
|
||||||
_encryptionField.label = "Encryption";
|
_encryptionField.label = "Encryption";
|
||||||
_encryptionField.style.width = 300;
|
_encryptionField.style.width = 300;
|
||||||
_encryptionField.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
|
|
||||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value;
|
AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value;
|
||||||
|
@ -107,53 +104,32 @@ namespace YooAsset.Editor
|
||||||
_encryptionField = new PopupField<string>();
|
_encryptionField = new PopupField<string>();
|
||||||
_encryptionField.label = "Encryption";
|
_encryptionField.label = "Encryption";
|
||||||
_encryptionField.style.width = 300;
|
_encryptionField.style.width = 300;
|
||||||
_encryptionField.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
|
|
||||||
encryptionContainer.Add(_encryptionField);
|
encryptionContainer.Add(_encryptionField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 压缩方式
|
||||||
|
_compressionField = root.Q<EnumField>("Compression");
|
||||||
|
_compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||||
|
_compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||||
|
_compressionField.style.width = 300;
|
||||||
|
_compressionField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
|
||||||
|
});
|
||||||
|
|
||||||
// 附加后缀格式
|
// 附加后缀格式
|
||||||
_appendExtensionToggle = root.Q<Toggle>("AppendExtension");
|
_appendExtensionToggle = root.Q<Toggle>("AppendExtension");
|
||||||
_appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension);
|
_appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension);
|
||||||
_appendExtensionToggle.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
|
|
||||||
_appendExtensionToggle.RegisterValueChangedCallback(evt =>
|
_appendExtensionToggle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
|
AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 强制构建
|
|
||||||
_forceRebuildToggle = root.Q<Toggle>("ForceRebuild");
|
|
||||||
_forceRebuildToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.ForceRebuild);
|
|
||||||
_forceRebuildToggle.SetEnabled(AssetBundleBuilderSettingData.Setting.DryRunBuild == false);
|
|
||||||
_forceRebuildToggle.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
|
||||||
AssetBundleBuilderSettingData.Setting.ForceRebuild = _forceRebuildToggle.value;
|
|
||||||
_buildTagsTxt.SetEnabled(_forceRebuildToggle.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 演练构建
|
|
||||||
_dryRunBuildToggle = root.Q<Toggle>("DryRunBuild");
|
|
||||||
_dryRunBuildToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.DryRunBuild);
|
|
||||||
_dryRunBuildToggle.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
|
||||||
AssetBundleBuilderSettingData.Setting.DryRunBuild = _dryRunBuildToggle.value;
|
|
||||||
_compressionField.SetEnabled(_dryRunBuildToggle.value == false);
|
|
||||||
_encryptionField.SetEnabled(_dryRunBuildToggle.value == false);
|
|
||||||
_appendExtensionToggle.SetEnabled(_dryRunBuildToggle.value == false);
|
|
||||||
_forceRebuildToggle.SetEnabled(_dryRunBuildToggle.value == false);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 内置标签
|
|
||||||
_buildTagsTxt = root.Q<TextField>("BuildinTags");
|
|
||||||
_buildTagsTxt.SetEnabled(_forceRebuildToggle.value);
|
|
||||||
_buildTagsTxt.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
|
|
||||||
_buildTagsTxt.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
|
||||||
AssetBundleBuilderSettingData.Setting.BuildTags = _buildTagsTxt.value;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 构建按钮
|
// 构建按钮
|
||||||
var buildButton = root.Q<Button>("Build");
|
var buildButton = root.Q<Button>("Build");
|
||||||
buildButton.clicked += BuildButton_clicked; ;
|
buildButton.clicked += BuildButton_clicked; ;
|
||||||
|
|
||||||
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -165,21 +141,18 @@ namespace YooAsset.Editor
|
||||||
AssetBundleBuilderSettingData.SaveFile();
|
AssetBundleBuilderSettingData.SaveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RefreshWindow()
|
||||||
|
{
|
||||||
|
bool enableElement = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild;
|
||||||
|
_buildTagsField.SetEnabled(enableElement);
|
||||||
|
_encryptionField.SetEnabled(enableElement);
|
||||||
|
_compressionField.SetEnabled(enableElement);
|
||||||
|
_appendExtensionToggle.SetEnabled(enableElement);
|
||||||
|
}
|
||||||
private void BuildButton_clicked()
|
private void BuildButton_clicked()
|
||||||
{
|
{
|
||||||
string title;
|
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||||
string content;
|
if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
|
||||||
if (_forceRebuildToggle.value)
|
|
||||||
{
|
|
||||||
title = "警告";
|
|
||||||
content = "确定开始强制构建吗,这样会删除所有已有构建的文件";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
title = "提示";
|
|
||||||
content = "确定开始增量构建吗";
|
|
||||||
}
|
|
||||||
if (EditorUtility.DisplayDialog(title, content, "Yes", "No"))
|
|
||||||
{
|
{
|
||||||
EditorTools.ClearUnityConsole();
|
EditorTools.ClearUnityConsole();
|
||||||
EditorApplication.delayCall += ExecuteBuild;
|
EditorApplication.delayCall += ExecuteBuild;
|
||||||
|
@ -197,35 +170,39 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||||
BuildParameters buildParameters = new BuildParameters();
|
BuildParameters buildParameters = new BuildParameters();
|
||||||
buildParameters.VerifyBuildingResult = true;
|
|
||||||
buildParameters.OutputRoot = defaultOutputRoot;
|
buildParameters.OutputRoot = defaultOutputRoot;
|
||||||
buildParameters.BuildTarget = _buildTarget;
|
buildParameters.BuildTarget = _buildTarget;
|
||||||
|
buildParameters.BuildMode = (EBuildMode)_buildModeField.value;
|
||||||
buildParameters.BuildVersion = _buildVersionField.value;
|
buildParameters.BuildVersion = _buildVersionField.value;
|
||||||
|
buildParameters.BuildinTags = _buildTagsField.value;
|
||||||
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
||||||
buildParameters.CompressOption = (ECompressOption)_compressionField.value;
|
|
||||||
buildParameters.AppendFileExtension = _appendExtensionToggle.value;
|
buildParameters.AppendFileExtension = _appendExtensionToggle.value;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
buildParameters.ForceRebuild = _forceRebuildToggle.value;
|
buildParameters.CompressOption = (ECompressOption)_compressionField.value;
|
||||||
buildParameters.DryRunBuild = _dryRunBuildToggle.value;
|
|
||||||
buildParameters.BuildinTags = _buildTagsTxt.value;
|
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
builder.Run(buildParameters);
|
builder.Run(buildParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// 加密类相关
|
||||||
/// 获取加密类的类型列表
|
private int GetEncryptionDefaultIndex(string className)
|
||||||
/// </summary>
|
{
|
||||||
|
for (int index = 0; index < _encryptionServicesClassNames.Count; index++)
|
||||||
|
{
|
||||||
|
if (_encryptionServicesClassNames[index] == className)
|
||||||
|
{
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
private List<Type> GetEncryptionServicesClassTypes()
|
private List<Type> GetEncryptionServicesClassTypes()
|
||||||
{
|
{
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IEncryptionServices>();
|
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IEncryptionServices>();
|
||||||
List<Type> classTypes = collection.ToList();
|
List<Type> classTypes = collection.ToList();
|
||||||
return classTypes;
|
return classTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建加密类的实例
|
|
||||||
/// </summary>
|
|
||||||
private IEncryptionServices CreateEncryptionServicesInstance()
|
private IEncryptionServices CreateEncryptionServicesInstance()
|
||||||
{
|
{
|
||||||
if (_encryptionField.index < 0)
|
if (_encryptionField.index < 0)
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
<ui:VisualElement name="BuildContainer">
|
<ui:VisualElement name="BuildContainer">
|
||||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||||
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
|
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
|
||||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
<uie:EnumField label="Build Mode" name="BuildMode" />
|
||||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||||
|
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||||
<ui:Toggle label="Append Extension" name="AppendExtension" style="height: 15px;" />
|
<ui:Toggle label="Append Extension" name="AppendExtension" style="height: 15px;" />
|
||||||
<ui:Toggle label="Force Rebuild" name="ForceRebuild" />
|
|
||||||
<ui:Toggle label="Dry Run Build" name="DryRunBuild" />
|
|
||||||
<ui:TextField picking-mode="Ignore" label="Buildin Tags" name="BuildinTags" />
|
<ui:TextField picking-mode="Ignore" label="Buildin Tags" name="BuildinTags" />
|
||||||
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public static class AssetBundleRuntimeBuilder
|
||||||
|
{
|
||||||
|
private static string _manifestFilePath = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 快速模式构建
|
||||||
|
/// </summary>
|
||||||
|
public static void FastBuild()
|
||||||
|
{
|
||||||
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||||
|
BuildParameters buildParameters = new BuildParameters();
|
||||||
|
buildParameters.OutputRoot = defaultOutputRoot;
|
||||||
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
|
buildParameters.BuildMode = EBuildMode.FastRunBuild;
|
||||||
|
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
||||||
|
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||||
|
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
||||||
|
|
||||||
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
|
bool buildResult = builder.Run(buildParameters);
|
||||||
|
if (buildResult)
|
||||||
|
{
|
||||||
|
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildTarget);
|
||||||
|
_manifestFilePath = $"{pipelineOutputDirectory}_{EBuildMode.FastRunBuild}/{YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildVersion)}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_manifestFilePath = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取构建的补丁清单文件路径
|
||||||
|
/// </summary>
|
||||||
|
public static string GetPatchManifestFilePath()
|
||||||
|
{
|
||||||
|
return _manifestFilePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -127,7 +127,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UnityEngine.Debug.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
|
BuildRunner.Log($"发现未被依赖的资源并自动移除 : {dependAssetPath}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BuildParameters
|
public class BuildParameters
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 验证构建结果
|
|
||||||
/// </summary>
|
|
||||||
public bool VerifyBuildingResult = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 输出的根目录
|
/// 输出的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -24,11 +19,28 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildTarget BuildTarget;
|
public BuildTarget BuildTarget;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建模式
|
||||||
|
/// </summary>
|
||||||
|
public EBuildMode BuildMode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的版本(资源版本号)
|
/// 构建的版本(资源版本号)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int BuildVersion;
|
public int BuildVersion;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置资源的标记列表
|
||||||
|
/// 注意:分号为分隔符
|
||||||
|
/// </summary>
|
||||||
|
public string BuildinTags;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证构建结果
|
||||||
|
/// </summary>
|
||||||
|
public bool VerifyBuildingResult = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -45,32 +57,16 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AppendFileExtension = false;
|
public bool AppendFileExtension = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密类
|
/// 加密类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEncryptionServices EncryptionServices;
|
public IEncryptionServices EncryptionServices = null;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 演练构建模式
|
|
||||||
/// </summary>
|
|
||||||
public bool DryRunBuild;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 强制重新构建整个项目,如果为FALSE则是增量打包
|
|
||||||
/// </summary>
|
|
||||||
public bool ForceRebuild;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 内置资源的标记列表
|
|
||||||
/// 注意:分号为分隔符
|
|
||||||
/// </summary>
|
|
||||||
public string BuildinTags;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 压缩选项
|
/// 压缩选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ECompressOption CompressOption;
|
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件名附加上哈希值
|
/// 文件名附加上哈希值
|
||||||
|
|
|
@ -28,11 +28,21 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildTarget BuildTarget;
|
public BuildTarget BuildTarget;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建模式
|
||||||
|
/// </summary>
|
||||||
|
public EBuildMode BuildMode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建版本
|
/// 构建版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int BuildVersion;
|
public int BuildVersion;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置资源标签
|
||||||
|
/// </summary>
|
||||||
|
public string BuildinTags;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -64,9 +74,6 @@ namespace YooAsset.Editor
|
||||||
public string EncryptionServicesClassName;
|
public string EncryptionServicesClassName;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
public bool DryRunBuild;
|
|
||||||
public bool ForceRebuild;
|
|
||||||
public string BuildinTags;
|
|
||||||
public ECompressOption CompressOption;
|
public ECompressOption CompressOption;
|
||||||
public bool AppendHash;
|
public bool AppendHash;
|
||||||
public bool DisableWriteTypeTree;
|
public bool DisableWriteTypeTree;
|
||||||
|
|
|
@ -8,6 +8,8 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildRunner
|
public class BuildRunner
|
||||||
{
|
{
|
||||||
|
public static bool EnableLog = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行构建流程
|
/// 执行构建流程
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -26,7 +28,7 @@ namespace YooAsset.Editor
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
|
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
|
||||||
Debug.Log($"---------------------------------------->{taskAttribute.Desc}");
|
Log($"---------------------------------------->{taskAttribute.Desc}");
|
||||||
task.Run(context);
|
task.Run(context);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -41,5 +43,16 @@ namespace YooAsset.Editor
|
||||||
// 返回运行结果
|
// 返回运行结果
|
||||||
return succeed;
|
return succeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 普通日志输出
|
||||||
|
/// </summary>
|
||||||
|
public static void Log(string info)
|
||||||
|
{
|
||||||
|
if (EnableLog)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Log(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,18 +21,23 @@ namespace YooAsset.Editor
|
||||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
|
// 快速构建模式下跳过引擎构建
|
||||||
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.FastRunBuild)
|
||||||
|
return;
|
||||||
|
|
||||||
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
||||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(buildParametersContext.PipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), opt, buildParametersContext.Parameters.BuildTarget);
|
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(buildParametersContext.PipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), opt, buildParametersContext.Parameters.BuildTarget);
|
||||||
if (unityManifest == null)
|
if (unityManifest == null)
|
||||||
throw new Exception("构建过程中发生错误!");
|
throw new Exception("构建过程中发生错误!");
|
||||||
|
|
||||||
Debug.Log("Unity引擎打包成功!");
|
BuildRunner.Log("Unity引擎打包成功!");
|
||||||
UnityManifestContext unityManifestContext = new UnityManifestContext();
|
UnityManifestContext unityManifestContext = new UnityManifestContext();
|
||||||
unityManifestContext.UnityManifest = unityManifest;
|
unityManifestContext.UnityManifest = unityManifest;
|
||||||
context.SetContextObject(unityManifestContext);
|
context.SetContextObject(unityManifestContext);
|
||||||
|
|
||||||
// 拷贝原生文件
|
// 拷贝原生文件
|
||||||
if (buildParametersContext.Parameters.DryRunBuild == false)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
// 注意:我们只有在强制重建的时候才会拷贝
|
// 注意:我们只有在强制重建的时候才会拷贝
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
if (buildParameters.Parameters.DryRunBuild == false && buildParameters.Parameters.ForceRebuild)
|
if (buildParameters.Parameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
{
|
{
|
||||||
// 清空流目录
|
// 清空流目录
|
||||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||||
|
@ -62,7 +62,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 刷新目录
|
// 刷新目录
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
Debug.Log($"内置文件拷贝完成:{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}");
|
BuildRunner.Log($"内置文件拷贝完成:{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,19 +34,19 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 创建补丁清单文件
|
// 创建补丁清单文件
|
||||||
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||||
UnityEngine.Debug.Log($"创建补丁清单文件:{manifestFilePath}");
|
BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}");
|
||||||
PatchManifest.Serialize(manifestFilePath, patchManifest);
|
PatchManifest.Serialize(manifestFilePath, patchManifest);
|
||||||
|
|
||||||
// 创建补丁清单哈希文件
|
// 创建补丁清单哈希文件
|
||||||
string manifestHashFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
string manifestHashFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||||
string manifestHash = HashUtility.FileMD5(manifestFilePath);
|
string manifestHash = HashUtility.FileMD5(manifestFilePath);
|
||||||
UnityEngine.Debug.Log($"创建补丁清单哈希文件:{manifestHashFilePath}");
|
BuildRunner.Log($"创建补丁清单哈希文件:{manifestHashFilePath}");
|
||||||
FileUtility.CreateFile(manifestHashFilePath, manifestHash);
|
FileUtility.CreateFile(manifestHashFilePath, manifestHash);
|
||||||
|
|
||||||
// 创建静态版本文件
|
// 创建静态版本文件
|
||||||
string staticVersionFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
string staticVersionFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||||
string staticVersion = resourceVersion.ToString();
|
string staticVersion = resourceVersion.ToString();
|
||||||
UnityEngine.Debug.Log($"创建静态版本文件:{staticVersionFilePath}");
|
BuildRunner.Log($"创建静态版本文件:{staticVersionFilePath}");
|
||||||
FileUtility.CreateFile(staticVersionFilePath, staticVersion);
|
FileUtility.CreateFile(staticVersionFilePath, staticVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,14 +61,15 @@ namespace YooAsset.Editor
|
||||||
// 内置标记列表
|
// 内置标记列表
|
||||||
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
|
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
|
||||||
|
|
||||||
bool dryRunBuild = buildParameters.Parameters.DryRunBuild;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
|
bool standardBuild = buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild;
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
var bundleName = bundleInfo.BundleName;
|
var bundleName = bundleInfo.BundleName;
|
||||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
|
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
|
||||||
string hash = GetFileHash(filePath, dryRunBuild);
|
string hash = GetFileHash(filePath, standardBuild);
|
||||||
string crc32 = GetFileCRC(filePath, dryRunBuild);
|
string crc32 = GetFileCRC(filePath, standardBuild);
|
||||||
long size = GetFileSize(filePath, dryRunBuild);
|
long size = GetFileSize(filePath, standardBuild);
|
||||||
string[] tags = buildMapContext.GetAssetTags(bundleName);
|
string[] tags = buildMapContext.GetAssetTags(bundleName);
|
||||||
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
|
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
|
||||||
bool isBuildin = IsBuildinBundle(tags, buildinTags);
|
bool isBuildin = IsBuildinBundle(tags, buildinTags);
|
||||||
|
@ -100,26 +101,26 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private string GetFileHash(string filePath, bool dryRunBuild)
|
private string GetFileHash(string filePath, bool standardBuild)
|
||||||
{
|
{
|
||||||
if (dryRunBuild)
|
if (standardBuild)
|
||||||
return "00000000000000000000000000000000"; //32位
|
|
||||||
else
|
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
|
||||||
private string GetFileCRC(string filePath, bool dryRunBuild)
|
|
||||||
{
|
|
||||||
if (dryRunBuild)
|
|
||||||
return "00000000"; //8位
|
|
||||||
else
|
else
|
||||||
|
return "00000000000000000000000000000000"; //32位
|
||||||
|
}
|
||||||
|
private string GetFileCRC(string filePath, bool standardBuild)
|
||||||
|
{
|
||||||
|
if (standardBuild)
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32(filePath);
|
||||||
}
|
|
||||||
private long GetFileSize(string filePath, bool dryRunBuild)
|
|
||||||
{
|
|
||||||
if (dryRunBuild)
|
|
||||||
return 0;
|
|
||||||
else
|
else
|
||||||
|
return "00000000"; //8位
|
||||||
|
}
|
||||||
|
private long GetFileSize(string filePath, bool standardBuild)
|
||||||
|
{
|
||||||
|
if (standardBuild)
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -9,7 +9,8 @@ namespace YooAsset.Editor
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
if (buildParameters.Parameters.DryRunBuild == false)
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
CopyPatchFiles(buildParameters);
|
CopyPatchFiles(buildParameters);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +23,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||||
string packageDirectory = buildParameters.GetPackageDirectory();
|
string packageDirectory = buildParameters.GetPackageDirectory();
|
||||||
UnityEngine.Debug.Log($"开始拷贝补丁文件到补丁包目录:{packageDirectory}");
|
BuildRunner.Log($"开始拷贝补丁文件到补丁包目录:{packageDirectory}");
|
||||||
|
|
||||||
// 拷贝Report文件
|
// 拷贝Report文件
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,9 @@ namespace YooAsset.Editor
|
||||||
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
||||||
buildReport.Summary.BuildSeconds = buildParameters.GetBuildingSeconds();
|
buildReport.Summary.BuildSeconds = buildParameters.GetBuildingSeconds();
|
||||||
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
||||||
|
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
|
||||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||||
|
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.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
|
||||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||||
|
@ -36,9 +38,6 @@ namespace YooAsset.Editor
|
||||||
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
buildReport.Summary.DryRunBuild = buildParameters.Parameters.DryRunBuild;
|
|
||||||
buildReport.Summary.ForceRebuild = buildParameters.Parameters.ForceRebuild;
|
|
||||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
|
||||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||||
buildReport.Summary.AppendHash = buildParameters.Parameters.AppendHash;
|
buildReport.Summary.AppendHash = buildParameters.Parameters.AppendHash;
|
||||||
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
|
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
|
||||||
|
@ -91,7 +90,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 序列化文件
|
// 序列化文件
|
||||||
BuildReport.Serialize(filePath, buildReport);
|
BuildReport.Serialize(filePath, buildReport);
|
||||||
UnityEngine.Debug.Log($"资源构建报告文件创建完成:{filePath}");
|
BuildRunner.Log($"资源构建报告文件创建完成:{filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -27,16 +27,17 @@ namespace YooAsset.Editor
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
if (buildParameters.Parameters.DryRunBuild)
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
EncryptionContext encryptionContext = new EncryptionContext();
|
EncryptionContext encryptionContext = new EncryptionContext();
|
||||||
encryptionContext.EncryptList = new List<string>();
|
encryptionContext.EncryptList = EncryptFiles(buildParameters, buildMapContext);
|
||||||
context.SetContextObject(encryptionContext);
|
context.SetContextObject(encryptionContext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EncryptionContext encryptionContext = new EncryptionContext();
|
EncryptionContext encryptionContext = new EncryptionContext();
|
||||||
encryptionContext.EncryptList = EncryptFiles(buildParameters, buildMapContext);
|
encryptionContext.EncryptList = new List<string>();
|
||||||
context.SetContextObject(encryptionContext);
|
context.SetContextObject(encryptionContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +76,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
byte[] bytes = encryptionServices.Encrypt(fileData);
|
byte[] bytes = encryptionServices.Encrypt(fileData);
|
||||||
File.WriteAllBytes(filePath, bytes);
|
File.WriteAllBytes(filePath, bytes);
|
||||||
UnityEngine.Debug.Log($"文件加密完成:{filePath}");
|
BuildRunner.Log($"文件加密完成:{filePath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
var buildMapContext = BuildMapCreater.CreateBuildMap();
|
var buildMapContext = BuildMapCreater.CreateBuildMap();
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
UnityEngine.Debug.Log("构建内容准备完毕!");
|
BuildRunner.Log("构建内容准备完毕!");
|
||||||
|
|
||||||
// 检测构建结果
|
// 检测构建结果
|
||||||
CheckBuildMapContent(buildMapContext);
|
CheckBuildMapContent(buildMapContext);
|
||||||
|
|
|
@ -27,7 +27,8 @@ namespace YooAsset.Editor
|
||||||
throw new Exception("输出目录不能为空");
|
throw new Exception("输出目录不能为空");
|
||||||
|
|
||||||
// 增量更新时候的必要检测
|
// 增量更新时候的必要检测
|
||||||
if (buildParameters.Parameters.DryRunBuild == false && buildParameters.Parameters.ForceRebuild == false)
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
// 检测历史版本是否存在
|
// 检测历史版本是否存在
|
||||||
if (AssetBundleBuilderHelper.HasAnyPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot) == false)
|
if (AssetBundleBuilderHelper.HasAnyPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot) == false)
|
||||||
|
@ -50,20 +51,20 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果是强制重建
|
// 如果是强制重建
|
||||||
if (buildParameters.Parameters.DryRunBuild == false && buildParameters.Parameters.ForceRebuild)
|
if (buildMode == EBuildMode.ForceRebuild)
|
||||||
{
|
{
|
||||||
// 删除平台总目录
|
// 删除平台总目录
|
||||||
string platformDirectory = $"{buildParameters.Parameters.OutputRoot}/{buildParameters.Parameters.BuildTarget}";
|
string platformDirectory = $"{buildParameters.Parameters.OutputRoot}/{buildParameters.Parameters.BuildTarget}";
|
||||||
if (EditorTools.DeleteDirectory(platformDirectory))
|
if (EditorTools.DeleteDirectory(platformDirectory))
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log($"删除平台总目录:{platformDirectory}");
|
BuildRunner.Log($"删除平台总目录:{platformDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果输出目录不存在
|
// 如果输出目录不存在
|
||||||
if (EditorTools.CreateDirectory(buildParameters.PipelineOutputDirectory))
|
if (EditorTools.CreateDirectory(buildParameters.PipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log($"创建输出目录:{buildParameters.PipelineOutputDirectory}");
|
BuildRunner.Log($"创建输出目录:{buildParameters.PipelineOutputDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,15 @@ namespace YooAsset.Editor
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
var unityManifestContext = context.GetContextObject<TaskBuilding.UnityManifestContext>();
|
|
||||||
|
// 快速构建模式下跳过验证
|
||||||
|
if (buildParametersContext.Parameters.BuildMode == EBuildMode.FastRunBuild)
|
||||||
|
return;
|
||||||
|
|
||||||
// 验证构建结果
|
// 验证构建结果
|
||||||
if (buildParametersContext.Parameters.VerifyBuildingResult)
|
if (buildParametersContext.Parameters.VerifyBuildingResult)
|
||||||
{
|
{
|
||||||
|
var unityManifestContext = context.GetContextObject<TaskBuilding.UnityManifestContext>();
|
||||||
VerifyingBuildingResult(context, unityManifestContext.UnityManifest);
|
VerifyingBuildingResult(context, unityManifestContext.UnityManifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +84,8 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 验证Asset
|
// 5. 验证Asset
|
||||||
if(buildParameters.Parameters.DryRunBuild == false)
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
foreach (var buildedBundle in buildedBundles)
|
foreach (var buildedBundle in buildedBundles)
|
||||||
|
@ -133,7 +138,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 卸载所有加载的Bundle
|
// 卸载所有加载的Bundle
|
||||||
Debug.Log("构建结果验证成功!");
|
BuildRunner.Log("构建结果验证成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包流水线的构建模式
|
||||||
|
/// </summary>
|
||||||
|
public enum EBuildMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 强制重建模式
|
||||||
|
/// </summary>
|
||||||
|
ForceRebuild,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增量构建模式
|
||||||
|
/// </summary>
|
||||||
|
IncrementalBuild,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 快速构建模式
|
||||||
|
/// </summary>
|
||||||
|
FastRunBuild,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 演练构建模式
|
||||||
|
/// </summary>
|
||||||
|
DryRunBuild,
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: b39dcdab07554ca4ab4ace5ca97aee78
|
guid: 0b6f2523a865e454d8fa3f48a2852d5a
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -96,6 +96,9 @@ namespace YooAsset.Editor
|
||||||
if (isRawAsset && CollectorType != ECollectorType.MainAssetCollector)
|
if (isRawAsset && CollectorType != ECollectorType.MainAssetCollector)
|
||||||
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(CollectPath))
|
||||||
|
throw new Exception($"The collect path is null or empty in grouper : {grouper.GrouperName}");
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 编辑器下运行时支持
|
|
||||||
/// </summary>
|
|
||||||
public static class AssetBundleGrouperRuntimeSupport
|
|
||||||
{
|
|
||||||
private static readonly Dictionary<string, CollectAssetInfo> _locationDic = new Dictionary<string, CollectAssetInfo>(1000);
|
|
||||||
|
|
||||||
public static void InitEditorPlayMode(bool enableAddressable)
|
|
||||||
{
|
|
||||||
_locationDic.Clear();
|
|
||||||
|
|
||||||
if (enableAddressable)
|
|
||||||
{
|
|
||||||
var collectAssetList = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
|
||||||
foreach (var collectAsset in collectAssetList)
|
|
||||||
{
|
|
||||||
if(collectAsset.CollectorType == ECollectorType.MainAssetCollector)
|
|
||||||
{
|
|
||||||
string address = collectAsset.Address;
|
|
||||||
if (_locationDic.ContainsKey(address))
|
|
||||||
throw new Exception($"The address is existed : {address} in grouper setting.");
|
|
||||||
else
|
|
||||||
_locationDic.Add(address, collectAsset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var collectAssetList = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
|
||||||
foreach (var collectAsset in collectAssetList)
|
|
||||||
{
|
|
||||||
if (collectAsset.CollectorType == ECollectorType.MainAssetCollector)
|
|
||||||
{
|
|
||||||
// 添加原始路径
|
|
||||||
// 注意:我们不允许原始路径存在重名
|
|
||||||
string assetPath = collectAsset.AssetPath;
|
|
||||||
if (_locationDic.ContainsKey(assetPath))
|
|
||||||
throw new Exception($"Asset path have existed : {assetPath}");
|
|
||||||
else
|
|
||||||
_locationDic.Add(assetPath, collectAsset);
|
|
||||||
|
|
||||||
// 添加去掉后缀名的路径
|
|
||||||
if (Path.HasExtension(assetPath))
|
|
||||||
{
|
|
||||||
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
|
|
||||||
if (_locationDic.ContainsKey(assetPathWithoutExtension))
|
|
||||||
UnityEngine.Debug.LogWarning($"Asset path have existed : {assetPathWithoutExtension}");
|
|
||||||
else
|
|
||||||
_locationDic.Add(assetPathWithoutExtension, collectAsset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static string ConvertLocationToAssetPath(string location)
|
|
||||||
{
|
|
||||||
// 检测地址合法性
|
|
||||||
CheckLocation(location);
|
|
||||||
|
|
||||||
if (_locationDic.ContainsKey(location))
|
|
||||||
{
|
|
||||||
return _locationDic[location].AssetPath;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogWarning($"Not found asset in grouper setting : {location}");
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static void CheckLocation(string location)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(location))
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogError("location param is null or empty!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 检查路径末尾是否有空格
|
|
||||||
int index = location.LastIndexOf(" ");
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
if (location.Length == index + 1)
|
|
||||||
UnityEngine.Debug.LogWarning($"Found blank character in location : \"{location}\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (location.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
|
|
||||||
UnityEngine.Debug.LogWarning($"Found illegal character in location : \"{location}\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -310,7 +310,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
var objectField = new ObjectField();
|
var objectField = new ObjectField();
|
||||||
objectField.name = "ObjectField1";
|
objectField.name = "ObjectField1";
|
||||||
objectField.label = "Collecter";
|
objectField.label = "Collector";
|
||||||
objectField.objectType = typeof(UnityEngine.Object);
|
objectField.objectType = typeof(UnityEngine.Object);
|
||||||
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
objectField.style.flexGrow = 1f;
|
objectField.style.flexGrow = 1f;
|
||||||
|
|
|
@ -66,7 +66,10 @@ namespace YooAsset.Editor
|
||||||
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildTime));
|
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildTime));
|
||||||
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
||||||
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
||||||
|
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
||||||
_items.Add(new ItemWrapper("构建版本", $"{buildReport.Summary.BuildVersion}"));
|
_items.Add(new ItemWrapper("构建版本", $"{buildReport.Summary.BuildVersion}"));
|
||||||
|
_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.EnableAutoCollect}"));
|
||||||
_items.Add(new ItemWrapper("追加文件扩展名", $"{buildReport.Summary.AppendFileExtension}"));
|
_items.Add(new ItemWrapper("追加文件扩展名", $"{buildReport.Summary.AppendFileExtension}"));
|
||||||
|
@ -76,9 +79,6 @@ 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("DryRunBuild", $"{buildReport.Summary.DryRunBuild}"));
|
|
||||||
_items.Add(new ItemWrapper("ForceRebuild", $"{buildReport.Summary.ForceRebuild}"));
|
|
||||||
_items.Add(new ItemWrapper("BuildinTags", $"{buildReport.Summary.BuildinTags}"));
|
|
||||||
_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("AppendHash", $"{buildReport.Summary.AppendHash}"));
|
||||||
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
|
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace YooAsset
|
||||||
// 1. 准备工作
|
// 1. 准备工作
|
||||||
if (_steps == ESteps.Prepare)
|
if (_steps == ESteps.Prepare)
|
||||||
{
|
{
|
||||||
if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.None)
|
if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromEditor)
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckAndCopyFile;
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
return; // 模拟实现异步操作
|
return; // 模拟实现异步操作
|
||||||
|
@ -130,7 +130,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_bundleInfo == null)
|
if (_bundleInfo == null)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
return _bundleInfo.BundleName;
|
return _bundleInfo.EditorAssetPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace YooAsset
|
||||||
LoadFromStreaming,
|
LoadFromStreaming,
|
||||||
LoadFromCache,
|
LoadFromCache,
|
||||||
LoadFromRemote,
|
LoadFromRemote,
|
||||||
|
LoadFromEditor,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly PatchBundle _patchBundle;
|
private readonly PatchBundle _patchBundle;
|
||||||
|
@ -32,6 +33,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal string RemoteFallbackURL { private set; get; }
|
internal string RemoteFallbackURL { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器资源路径
|
||||||
|
/// </summary>
|
||||||
|
public string EditorAssetPath { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -113,6 +119,16 @@ namespace YooAsset
|
||||||
BundleName = patchBundle.BundleName;
|
BundleName = patchBundle.BundleName;
|
||||||
RemoteMainURL = mainURL;
|
RemoteMainURL = mainURL;
|
||||||
RemoteFallbackURL = fallbackURL;
|
RemoteFallbackURL = fallbackURL;
|
||||||
|
EditorAssetPath = string.Empty;
|
||||||
|
}
|
||||||
|
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath)
|
||||||
|
{
|
||||||
|
_patchBundle = patchBundle;
|
||||||
|
LoadMode = loadMode;
|
||||||
|
BundleName = patchBundle.BundleName;
|
||||||
|
RemoteMainURL = string.Empty;
|
||||||
|
RemoteFallbackURL = string.Empty;
|
||||||
|
EditorAssetPath = editorAssetPath;
|
||||||
}
|
}
|
||||||
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
||||||
{
|
{
|
||||||
|
@ -121,6 +137,7 @@ namespace YooAsset
|
||||||
BundleName = patchBundle.BundleName;
|
BundleName = patchBundle.BundleName;
|
||||||
RemoteMainURL = string.Empty;
|
RemoteMainURL = string.Empty;
|
||||||
RemoteFallbackURL = string.Empty;
|
RemoteFallbackURL = string.Empty;
|
||||||
|
EditorAssetPath = string.Empty;
|
||||||
}
|
}
|
||||||
internal BundleInfo(string bundleName)
|
internal BundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
|
@ -129,6 +146,7 @@ namespace YooAsset
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
RemoteMainURL = string.Empty;
|
RemoteMainURL = string.Empty;
|
||||||
RemoteFallbackURL = string.Empty;
|
RemoteFallbackURL = string.Empty;
|
||||||
|
EditorAssetPath = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
|
@ -16,12 +17,50 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class EditorPlayModeInitializationOperation : InitializationOperation
|
internal sealed class EditorPlayModeInitializationOperation : InitializationOperation
|
||||||
{
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Builder,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly EditorPlayModeImpl _impl;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
internal EditorPlayModeInitializationOperation(EditorPlayModeImpl impl)
|
||||||
|
{
|
||||||
|
_impl = impl;
|
||||||
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
Status = EOperationStatus.Succeed;
|
_steps = ESteps.Builder;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
|
if (_steps == ESteps.Builder)
|
||||||
|
{
|
||||||
|
string manifestFilePath = EditorPlayModeHelper.DryRunBuild();
|
||||||
|
if (string.IsNullOrEmpty(manifestFilePath))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Dry run build failed, see the detail info on the console window.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (File.Exists(manifestFilePath) == false)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Manifest file not found : {manifestFilePath}";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
YooLogger.Log($"Load manifest file in editor play mode : {manifestFilePath}");
|
||||||
|
string jsonContent = FileUtility.ReadFile(manifestFilePath);
|
||||||
|
_impl.AppPatchManifest = PatchManifest.Deserialize(jsonContent);
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +191,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置补丁清单加载器
|
/// 内置补丁清单加载器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -51,10 +51,10 @@ namespace YooAsset
|
||||||
public readonly Dictionary<string, PatchAsset> Assets = new Dictionary<string, PatchAsset>();
|
public readonly Dictionary<string, PatchAsset> Assets = new Dictionary<string, PatchAsset>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可寻址地址映射集合
|
/// 资源路径映射集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public readonly Dictionary<string, string> AddressDic = new Dictionary<string, string>();
|
public readonly Dictionary<string, string> AssetPathMapping = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -120,17 +120,39 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可寻址地址转换为资源路径
|
/// 尝试获取资源包的主资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ConvertAddress(string address)
|
public string TryGetBundleMainAssetPath(string bundleName)
|
||||||
{
|
{
|
||||||
if (AddressDic.TryGetValue(address, out string assetPath))
|
foreach (var patchAsset in AssetList)
|
||||||
|
{
|
||||||
|
int bundleID = patchAsset.BundleID;
|
||||||
|
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||||
|
{
|
||||||
|
var patchBundle = BundleList[bundleID];
|
||||||
|
if (patchBundle.BundleName == bundleName)
|
||||||
|
return patchAsset.AssetPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid depend id : {bundleID} Asset path : {patchAsset.AssetPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 映射为资源路径
|
||||||
|
/// </summary>
|
||||||
|
public string MappingToAssetPath(string location)
|
||||||
|
{
|
||||||
|
if (AssetPathMapping.TryGetValue(location, out string assetPath))
|
||||||
{
|
{
|
||||||
return assetPath;
|
return assetPath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Not found address in patch manifest : {address}");
|
YooLogger.Warning($"Failed to mapping location to asset path : {location}");
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,36 +184,47 @@ namespace YooAsset
|
||||||
// AssetList
|
// AssetList
|
||||||
foreach (var patchAsset in patchManifest.AssetList)
|
foreach (var patchAsset in patchManifest.AssetList)
|
||||||
{
|
{
|
||||||
string assetPath = patchAsset.AssetPath;
|
|
||||||
|
|
||||||
// 添加原始路径
|
|
||||||
// 注意:我们不允许原始路径存在重名
|
// 注意:我们不允许原始路径存在重名
|
||||||
|
string assetPath = patchAsset.AssetPath;
|
||||||
if (patchManifest.Assets.ContainsKey(assetPath))
|
if (patchManifest.Assets.ContainsKey(assetPath))
|
||||||
throw new Exception($"Asset path have existed : {assetPath}");
|
throw new Exception($"AssetPath have existed : {assetPath}");
|
||||||
else
|
else
|
||||||
patchManifest.Assets.Add(assetPath, patchAsset);
|
patchManifest.Assets.Add(assetPath, patchAsset);
|
||||||
|
|
||||||
// 添加去掉后缀名的路径
|
|
||||||
if (Path.HasExtension(assetPath))
|
|
||||||
{
|
|
||||||
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
|
|
||||||
if (patchManifest.Assets.ContainsKey(assetPathWithoutExtension))
|
|
||||||
YooLogger.Warning($"Asset path have existed : {assetPathWithoutExtension}");
|
|
||||||
else
|
|
||||||
patchManifest.Assets.Add(assetPathWithoutExtension, patchAsset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Address
|
// AssetPathMapping
|
||||||
if (patchManifest.EnableAddressable)
|
if (patchManifest.EnableAddressable)
|
||||||
{
|
{
|
||||||
foreach (var patchAsset in patchManifest.AssetList)
|
foreach (var patchAsset in patchManifest.AssetList)
|
||||||
{
|
{
|
||||||
string address = patchAsset.Address;
|
string address = patchAsset.Address;
|
||||||
if (patchManifest.AddressDic.ContainsKey(address))
|
if (patchManifest.AssetPathMapping.ContainsKey(address))
|
||||||
throw new Exception($"Address have existed : {address}");
|
throw new Exception($"Address have existed : {address}");
|
||||||
else
|
else
|
||||||
patchManifest.AddressDic.Add(address, patchAsset.AssetPath);
|
patchManifest.AssetPathMapping.Add(address, patchAsset.AssetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var patchAsset in patchManifest.AssetList)
|
||||||
|
{
|
||||||
|
string assetPath = patchAsset.AssetPath;
|
||||||
|
|
||||||
|
// 添加原生路径的映射
|
||||||
|
if (patchManifest.AssetPathMapping.ContainsKey(assetPath))
|
||||||
|
throw new Exception($"AssetPath have existed : {assetPath}");
|
||||||
|
else
|
||||||
|
patchManifest.AssetPathMapping.Add(assetPath, assetPath);
|
||||||
|
|
||||||
|
// 添加无后缀名路径的映射
|
||||||
|
if (Path.HasExtension(assetPath))
|
||||||
|
{
|
||||||
|
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
|
||||||
|
if (patchManifest.AssetPathMapping.ContainsKey(assetPathWithoutExtension))
|
||||||
|
YooLogger.Warning($"AssetPath have existed : {assetPathWithoutExtension}");
|
||||||
|
else
|
||||||
|
patchManifest.AssetPathMapping.Add(assetPathWithoutExtension, assetPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,19 @@ using System.Reflection;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal static class LocationServicesHelper
|
internal static class EditorPlayModeHelper
|
||||||
{
|
{
|
||||||
private static System.Type _classType;
|
private static System.Type _classType;
|
||||||
|
|
||||||
public static void InitEditorPlayMode(bool enableAddressable)
|
public static string DryRunBuild()
|
||||||
{
|
{
|
||||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleGrouperRuntimeSupport");
|
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleRuntimeBuilder");
|
||||||
InvokePublicStaticMethod(_classType, "InitEditorPlayMode", enableAddressable);
|
InvokePublicStaticMethod(_classType, "FastBuild");
|
||||||
|
return GetPatchManifestFilePath();
|
||||||
}
|
}
|
||||||
public static string ConvertLocationToAssetPath(string location)
|
private static string GetPatchManifestFilePath()
|
||||||
{
|
{
|
||||||
return (string)InvokePublicStaticMethod(_classType, "ConvertLocationToAssetPath", location);
|
return (string)InvokePublicStaticMethod(_classType, "GetPatchManifestFilePath");
|
||||||
}
|
}
|
||||||
private static object InvokePublicStaticMethod(System.Type type, string method, params object[] parameters)
|
private static object InvokePublicStaticMethod(System.Type type, string method, params object[] parameters)
|
||||||
{
|
{
|
||||||
|
@ -28,4 +29,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
internal static class EditorPlayModeHelper
|
||||||
|
{
|
||||||
|
public static string DryRunBuild() { throw new System.Exception("Only support in unity editor !"); }
|
||||||
|
}
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5b09fe4b7aa2d2143bc538976541b039
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -6,12 +6,14 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class EditorPlayModeImpl : IBundleServices
|
internal class EditorPlayModeImpl : IBundleServices
|
||||||
{
|
{
|
||||||
|
internal PatchManifest AppPatchManifest;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync()
|
public InitializationOperation InitializeAsync()
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeInitializationOperation();
|
var operation = new EditorPlayModeInitializationOperation(this);
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -21,27 +23,41 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int GetResourceVersion()
|
public int GetResourceVersion()
|
||||||
{
|
{
|
||||||
return 0;
|
if (AppPatchManifest == null)
|
||||||
|
return 0;
|
||||||
|
return AppPatchManifest.ResourceVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Editor play mode can not get bundle info.");
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
return new BundleInfo(string.Empty);
|
||||||
return bundleInfo;
|
|
||||||
|
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||||
|
{
|
||||||
|
string mainAssetPath = AppPatchManifest.TryGetBundleMainAssetPath(bundleName);
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, mainAssetPath);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
string IBundleServices.ConvertAddress(string address)
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
throw new Exception($"Editor play mode not support addressable.");
|
return AppPatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.GetBundleName(string assetPath)
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
{
|
{
|
||||||
return assetPath;
|
return AppPatchManifest.GetBundleName(assetPath);
|
||||||
}
|
}
|
||||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||||
{
|
{
|
||||||
return new string[] { };
|
return AppPatchManifest.GetAllDependencies(assetPath);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,9 +309,9 @@ namespace YooAsset
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string IBundleServices.ConvertAddress(string address)
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return LocalPatchManifest.ConvertAddress(address);
|
return LocalPatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.GetBundleName(string assetPath)
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,9 +56,9 @@ namespace YooAsset
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string IBundleServices.ConvertAddress(string address)
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return AppPatchManifest.ConvertAddress(address);
|
return AppPatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.GetBundleName(string assetPath)
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,9 +9,9 @@ namespace YooAsset
|
||||||
BundleInfo GetBundleInfo(string bundleName);
|
BundleInfo GetBundleInfo(string bundleName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可寻址地址转换为资源路径
|
/// 映射为资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string ConvertAddress(string address);
|
string MappingToAssetPath(string location);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源所属的资源包名称
|
/// 获取资源所属的资源包名称
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 定位地址转换为资源路径
|
/// 定位地址转换为资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string ConvertLocationToAssetPath(YooAssets.EPlayMode playMode, string location);
|
string ConvertLocationToAssetPath(string location);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,27 +3,9 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
public class AddressLocationServices : ILocationServices
|
public class AddressLocationServices : ILocationServices
|
||||||
{
|
{
|
||||||
public AddressLocationServices()
|
public string ConvertLocationToAssetPath(string location)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
return YooAssets.MappingToAssetPath(location);
|
||||||
LocationServicesHelper.InitEditorPlayMode(true);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ConvertLocationToAssetPath(YooAssets.EPlayMode playMode, string location)
|
|
||||||
{
|
|
||||||
if (playMode == YooAssets.EPlayMode.EditorPlayMode)
|
|
||||||
{
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
return LocationServicesHelper.ConvertLocationToAssetPath(location);
|
|
||||||
#else
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return YooAssets.ConvertAddress(location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,34 +9,19 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(resourceRoot) == false)
|
if (string.IsNullOrEmpty(resourceRoot) == false)
|
||||||
_resourceRoot = PathHelper.GetRegularPath(resourceRoot);
|
_resourceRoot = PathHelper.GetRegularPath(resourceRoot);
|
||||||
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
public string ConvertLocationToAssetPath(string location)
|
||||||
LocationServicesHelper.InitEditorPlayMode(false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
public string ConvertLocationToAssetPath(YooAssets.EPlayMode playMode, string location)
|
|
||||||
{
|
{
|
||||||
location = CombineAssetPath(_resourceRoot, location);
|
if (string.IsNullOrEmpty(_resourceRoot))
|
||||||
if (playMode == YooAssets.EPlayMode.EditorPlayMode)
|
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
return YooAssets.MappingToAssetPath(location);
|
||||||
return LocationServicesHelper.ConvertLocationToAssetPath(location);
|
|
||||||
#else
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return location;
|
string tempLocation = $"{_resourceRoot}/{location}";
|
||||||
|
return YooAssets.MappingToAssetPath(tempLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private string CombineAssetPath(string root, string location)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(root))
|
|
||||||
return location;
|
|
||||||
else
|
|
||||||
return $"{root}/{location}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -310,7 +310,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static BundleInfo GetBundleInfo(string location)
|
public static BundleInfo GetBundleInfo(string location)
|
||||||
{
|
{
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
string bundleName = _bundleServices.GetBundleName(assetPath);
|
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||||
return _bundleServices.GetBundleInfo(bundleName);
|
return _bundleServices.GetBundleInfo(bundleName);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ namespace YooAsset
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||||
{
|
{
|
||||||
string scenePath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
string scenePath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -367,10 +367,11 @@ namespace YooAsset
|
||||||
/// <param name="copyPath">拷贝路径</param>
|
/// <param name="copyPath">拷贝路径</param>
|
||||||
public static RawFileOperation GetRawFileAsync(string location, string copyPath = null)
|
public static RawFileOperation GetRawFileAsync(string location, string copyPath = null)
|
||||||
{
|
{
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = new BundleInfo(assetPath);
|
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||||
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(bundleName);
|
||||||
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
|
@ -482,7 +483,7 @@ namespace YooAsset
|
||||||
|
|
||||||
private static AssetOperationHandle LoadAssetInternal(string location, System.Type assetType, bool waitForAsyncComplete)
|
private static AssetOperationHandle LoadAssetInternal(string location, System.Type assetType, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
var handle = AssetSystem.LoadAssetAsync(assetPath, assetType);
|
var handle = AssetSystem.LoadAssetAsync(assetPath, assetType);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
|
@ -490,7 +491,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
private static SubAssetsOperationHandle LoadSubAssetsInternal(string location, System.Type assetType, bool waitForAsyncComplete)
|
private static SubAssetsOperationHandle LoadSubAssetsInternal(string location, System.Type assetType, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
var handle = AssetSystem.LoadSubAssetsAsync(assetPath, assetType);
|
var handle = AssetSystem.LoadSubAssetsAsync(assetPath, assetType);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
|
@ -583,7 +584,7 @@ namespace YooAsset
|
||||||
List<string> assetPaths = new List<string>(locations.Length);
|
List<string> assetPaths = new List<string>(locations.Length);
|
||||||
foreach (var location in locations)
|
foreach (var location in locations)
|
||||||
{
|
{
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
assetPaths.Add(assetPath);
|
assetPaths.Add(assetPath);
|
||||||
}
|
}
|
||||||
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetPaths, downloadingMaxNumber, failedTryAgain);
|
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetPaths, downloadingMaxNumber, failedTryAgain);
|
||||||
|
@ -731,10 +732,37 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal static string ConvertAddress(string address)
|
internal static string MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return _bundleServices.ConvertAddress(address);
|
#if UNITY_EDITOR
|
||||||
|
CheckLocation(location);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return _bundleServices.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
private static void CheckLocation(string location)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(location))
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.LogError("location param is null or empty!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 检查路径末尾是否有空格
|
||||||
|
int index = location.LastIndexOf(" ");
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
if (location.Length == index + 1)
|
||||||
|
UnityEngine.Debug.LogWarning($"Found blank character in location : \"{location}\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.IndexOfAny(System.IO.Path.GetInvalidPathChars()) >= 0)
|
||||||
|
UnityEngine.Debug.LogWarning($"Found illegal character in location : \"{location}\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue