mirror of https://github.com/tuyoogame/YooAsset
Update editor logic
parent
50bfde6e8e
commit
e1801a5fba
|
@ -86,7 +86,8 @@ namespace YooAsset.Editor
|
|||
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageDirectory();
|
||||
buildResult.OutputPackageCRC = buildParametersContext.OutputPackageCRC;
|
||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||
}
|
||||
else
|
||||
|
|
|
@ -25,14 +25,6 @@ namespace YooAsset.Editor
|
|||
return $"{Application.dataPath}/StreamingAssets/YooAssets/";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
public static string MakePipelineOutputDirectory(string outputRoot, BuildTarget buildTarget)
|
||||
{
|
||||
return $"{outputRoot}/{buildTarget}/{YooAssetSettings.OutputFolderName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空流文件夹
|
||||
/// </summary>
|
||||
|
@ -67,61 +59,25 @@ namespace YooAsset.Editor
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有补丁包版本列表
|
||||
/// 注意:列表会按照版本号从小到大排序
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
private static List<int> GetPackageVersionList(BuildTarget buildTarget, string outputRoot)
|
||||
public static string MakePipelineOutputDirectory(string outputRoot, string buildPackage, BuildTarget buildTarget, EBuildMode buildMode)
|
||||
{
|
||||
List<int> versionList = new List<int>();
|
||||
|
||||
string parentPath = $"{outputRoot}/{buildTarget}";
|
||||
if (Directory.Exists(parentPath) == false)
|
||||
return versionList;
|
||||
|
||||
// 获取所有补丁包文件夹
|
||||
string[] allFolders = Directory.GetDirectories(parentPath);
|
||||
for (int i = 0; i < allFolders.Length; i++)
|
||||
{
|
||||
string folderName = Path.GetFileNameWithoutExtension(allFolders[i]);
|
||||
if (int.TryParse(folderName, out int version))
|
||||
versionList.Add(version);
|
||||
string result = $"{outputRoot}/{buildPackage}/{buildTarget}/{YooAssetSettings.OutputFolderName}";
|
||||
if (buildMode == EBuildMode.DryRunBuild)
|
||||
result += $"_{EBuildMode.DryRunBuild}";
|
||||
else if (buildMode == EBuildMode.SimulateBuild)
|
||||
result += $"_{EBuildMode.SimulateBuild}";
|
||||
return result;
|
||||
}
|
||||
|
||||
// 从小到大排序
|
||||
versionList.Sort();
|
||||
return versionList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前最大的补丁包版本号
|
||||
/// </summary>
|
||||
/// <returns>如果没有任何补丁版本,那么返回-1</returns>
|
||||
public static int GetMaxPackageVersion(BuildTarget buildTarget, string outputRoot)
|
||||
{
|
||||
List<int> versionList = GetPackageVersionList(buildTarget, outputRoot);
|
||||
if (versionList.Count == 0)
|
||||
return -1;
|
||||
return versionList[versionList.Count - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在任何补丁包版本
|
||||
/// </summary>
|
||||
public static bool HasAnyPackageVersion(BuildTarget buildTarget, string outputRoot)
|
||||
{
|
||||
List<int> versionList = GetPackageVersionList(buildTarget, outputRoot);
|
||||
return versionList.Count > 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载补丁清单文件
|
||||
/// </summary>
|
||||
internal static PatchManifest LoadPatchManifestFile(string fileDirectory, int resourceVersion)
|
||||
internal static PatchManifest LoadPatchManifestFile(string fileDirectory, string packageName, string packageCRC)
|
||||
{
|
||||
string filePath = $"{fileDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||
string filePath = $"{fileDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC)}";
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
throw new System.Exception($"Not found patch manifest file : {filePath}");
|
||||
|
@ -130,16 +86,5 @@ namespace YooAsset.Editor
|
|||
string jsonData = FileUtility.ReadFile(filePath);
|
||||
return PatchManifest.Deserialize(jsonData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取旧的补丁清单
|
||||
/// </summary>
|
||||
internal static PatchManifest GetOldPatchManifest(string pipelineOutputDirectory)
|
||||
{
|
||||
string staticVersionFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string staticVersionContent = FileUtility.ReadFile(staticVersionFilePath);
|
||||
int staticVersion = int.Parse(staticVersionContent);
|
||||
return LoadPatchManifestFile(pipelineOutputDirectory, staticVersion);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,11 +5,6 @@ namespace YooAsset.Editor
|
|||
{
|
||||
public class AssetBundleBuilderSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建版本号
|
||||
/// </summary>
|
||||
public int BuildVersion = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
|
|
|
@ -25,7 +25,6 @@ namespace YooAsset.Editor
|
|||
|
||||
private Button _saveButton;
|
||||
private TextField _buildOutputField;
|
||||
private IntegerField _buildVersionField;
|
||||
private EnumField _buildPipelineField;
|
||||
private EnumField _buildModeField;
|
||||
private TextField _buildinTagsField;
|
||||
|
@ -63,20 +62,10 @@ namespace YooAsset.Editor
|
|||
|
||||
// 输出目录
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(defaultOutputRoot, _buildTarget);
|
||||
_buildOutputField = root.Q<TextField>("BuildOutput");
|
||||
_buildOutputField.SetValueWithoutNotify(pipelineOutputDirectory);
|
||||
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
||||
_buildOutputField.SetEnabled(false);
|
||||
|
||||
// 构建版本
|
||||
_buildVersionField = root.Q<IntegerField>("BuildVersion");
|
||||
_buildVersionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildVersion);
|
||||
_buildVersionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value;
|
||||
});
|
||||
|
||||
// 构建管线
|
||||
_buildPipelineField = root.Q<EnumField>("BuildPipeline");
|
||||
_buildPipelineField.Init(AssetBundleBuilderSettingData.Setting.BuildPipeline);
|
||||
|
@ -249,7 +238,6 @@ namespace YooAsset.Editor
|
|||
buildParameters.BuildTarget = _buildTarget;
|
||||
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
||||
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
||||
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
|
@ -269,7 +257,7 @@ namespace YooAsset.Editor
|
|||
var buildResult = builder.Run(buildParameters);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
EditorUtility.RevealInFinder($"{buildParameters.OutputRoot}/{buildParameters.BuildTarget}/{buildParameters.BuildVersion}");
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
</uie:Toolbar>
|
||||
<ui:VisualElement name="BuildContainer">
|
||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
|
||||
<uie:EnumField label="Build Pipeline" name="BuildPipeline" />
|
||||
<uie:EnumField label="Build Mode" name="BuildMode" />
|
||||
<ui:VisualElement name="BuildPackageContainer" style="height: 24px;" />
|
||||
|
|
|
@ -16,7 +16,6 @@ namespace YooAsset.Editor
|
|||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.BuildVersion = 999;
|
||||
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
|
||||
|
@ -24,8 +23,9 @@ namespace YooAsset.Editor
|
|||
var buildResult = builder.Run(buildParameters);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildTarget);
|
||||
_manifestFilePath = $"{pipelineOutputDirectory}_{EBuildMode.SimulateBuild}/{YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildVersion)}";
|
||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildPackage, buildParameters.BuildTarget, buildParameters.BuildMode);
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildResult.OutputPackageCRC);
|
||||
_manifestFilePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -61,11 +61,6 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public string BuildPackage;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的版本(资源版本号)
|
||||
/// </summary>
|
||||
public int BuildVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源标签集合(首包资源标签)
|
||||
/// 注意:分号为分隔符
|
||||
|
|
|
@ -9,34 +9,61 @@ namespace YooAsset.Editor
|
|||
{
|
||||
private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
|
||||
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
private string _outputPackageCRC = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public BuildParameters Parameters { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线的输出目录
|
||||
/// 构建输出的包裹清单哈希值
|
||||
/// </summary>
|
||||
public string PipelineOutputDirectory { private set; get; }
|
||||
public string OutputPackageCRC
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_outputPackageCRC))
|
||||
throw new Exception("Output package file CRC32 is empty !");
|
||||
return _outputPackageCRC;
|
||||
}
|
||||
set
|
||||
{
|
||||
_outputPackageCRC = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public BuildParametersContext(BuildParameters parameters)
|
||||
{
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
||||
if (parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
|
||||
else if (parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetPipelineOutputDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||
{
|
||||
_pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(Parameters.OutputRoot, Parameters.BuildPackage, Parameters.BuildTarget, Parameters.BuildMode);
|
||||
}
|
||||
return _pipelineOutputDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁目录
|
||||
/// </summary>
|
||||
public string GetPackageDirectory()
|
||||
public string GetPackageOutputDirectory()
|
||||
{
|
||||
return $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.BuildVersion}";
|
||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||
{
|
||||
_packageOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.BuildPackage}/{Parameters.BuildTarget}/{OutputPackageCRC}";
|
||||
}
|
||||
return _packageOutputDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -86,7 +113,8 @@ namespace YooAsset.Editor
|
|||
throw new Exception("Should never get here !");
|
||||
|
||||
var targetGroup = BuildPipeline.GetBuildTargetGroup(Parameters.BuildTarget);
|
||||
var buildParams = new UnityEditor.Build.Pipeline.BundleBuildParameters(Parameters.BuildTarget, targetGroup, PipelineOutputDirectory);
|
||||
var pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||
var buildParams = new UnityEditor.Build.Pipeline.BundleBuildParameters(Parameters.BuildTarget, targetGroup, pipelineOutputDirectory);
|
||||
|
||||
if (Parameters.CompressOption == ECompressOption.Uncompressed)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
|
||||
|
|
|
@ -44,9 +44,9 @@ namespace YooAsset.Editor
|
|||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建版本
|
||||
/// 构建包裹
|
||||
/// </summary>
|
||||
public int BuildVersion;
|
||||
public string BuildPackage;
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源标签
|
||||
|
|
|
@ -25,5 +25,10 @@ namespace YooAsset.Editor
|
|||
/// 输出的补丁包目录
|
||||
/// </summary>
|
||||
public string OutputPackageDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// 输出的包裹清单哈希值
|
||||
/// </summary>
|
||||
public string OutputPackageCRC;
|
||||
}
|
||||
}
|
|
@ -25,14 +25,15 @@ namespace YooAsset.Editor
|
|||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
||||
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(buildParametersContext.PipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), opt, buildParametersContext.Parameters.BuildTarget);
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
BuildAssetBundleOptions buildOptions = buildParametersContext.GetPipelineBuildOptions();
|
||||
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
if (buildResults == null)
|
||||
throw new Exception("构建过程中发生错误!");
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
string unityOutputManifestFilePath = $"{buildParametersContext.PipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
string unityOutputManifestFilePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/{YooAssetSettings.OutputFolderName}";
|
||||
if(System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
|
||||
}
|
||||
|
@ -54,11 +55,12 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if (buildAsset.IsRawAsset)
|
||||
|
@ -73,11 +75,12 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
private void UpdateBuildBundleInfo(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext, BuildResultContext buildResult)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
bundleInfo.ContentHash = HashUtility.FileMD5(filePath);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -58,11 +58,12 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if (buildAsset.IsRawAsset)
|
||||
|
@ -77,11 +78,12 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
private void UpdateBuildBundleInfo(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext, BuildResultContext buildResult)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
bundleInfo.ContentHash = HashUtility.FileMD5(filePath);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -11,22 +11,26 @@ namespace YooAsset.Editor
|
|||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
// 注意:我们只有在强制重建的时候才会拷贝
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParameters.Parameters.CopyBuildinTagFiles)
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.CopyBuildinTagFiles)
|
||||
{
|
||||
// 清空流目录
|
||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||
|
||||
// 拷贝内置文件
|
||||
CopyBuildinFilesToStreaming(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||
CopyBuildinFilesToStreaming(buildParametersContext);
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyBuildinFilesToStreaming(string pipelineOutputDirectory, int buildVersion)
|
||||
private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string streamingAssetsOutputDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath();
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageName = buildParametersContext.Parameters.BuildPackage;
|
||||
string packageCRC = buildParametersContext.OutputPackageCRC;
|
||||
|
||||
// 加载补丁清单
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildVersion);
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, packageName, packageCRC);
|
||||
|
||||
// 拷贝文件列表
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
|
@ -35,34 +39,29 @@ namespace YooAsset.Editor
|
|||
continue;
|
||||
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{patchBundle.FileName}";
|
||||
string destPath = $"{streamingAssetsOutputDirectory}/{patchBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝清单文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(buildVersion)}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.GetPatchManifestFileName(buildVersion)}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝清单哈希文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(buildVersion)}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.GetPatchManifestHashFileName(buildVersion)}";
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC);
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
||||
string destPath = $"{streamingAssetsOutputDirectory}/{manifestFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝静态版本文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettings.VersionFileName}";
|
||||
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(packageName);
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{versionFileName}";
|
||||
string destPath = $"{streamingAssetsOutputDirectory}/{versionFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildRunner.Log($"内置文件拷贝完成:{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}");
|
||||
BuildRunner.Log($"内置文件拷贝完成:{streamingAssetsOutputDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,23 +21,24 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
private void CreatePatchManifestFile(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
|
||||
// 创建新补丁清单
|
||||
PatchManifest patchManifest = new PatchManifest();
|
||||
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
||||
patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion;
|
||||
patchManifest.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
||||
patchManifest.OutputNameStyle = (int)buildParameters.Parameters.OutputNameStyle;
|
||||
patchManifest.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||
patchManifest.EnableAddressable = buildParameters.EnableAddressable;
|
||||
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
||||
patchManifest.PackageName = buildParameters.BuildPackage;
|
||||
patchManifest.BuildinTags = buildParameters.BuildinTags;
|
||||
patchManifest.BundleList = GetAllPatchBundle(context);
|
||||
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
||||
|
||||
// 更新Unity内置资源包的引用关系
|
||||
if (buildParameters.Parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
if(buildParameters.Parameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||
if(buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results);
|
||||
|
@ -45,21 +46,24 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 创建补丁清单文件
|
||||
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||
BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}");
|
||||
PatchManifest.Serialize(manifestFilePath, patchManifest);
|
||||
string manifestFileTempName = YooAssetSettingsData.GetPatchManifestTempFileName(buildParameters.BuildPackage);
|
||||
string manifestFileTempPath = $"{pipelineOutputDirectory}/{manifestFileTempName}";
|
||||
BuildRunner.Log($"创建补丁清单文件:{manifestFileTempPath}");
|
||||
PatchManifest.Serialize(manifestFileTempPath, patchManifest);
|
||||
|
||||
// 创建补丁清单哈希文件
|
||||
string manifestHashFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||
string manifestHash = HashUtility.FileMD5(manifestFilePath);
|
||||
BuildRunner.Log($"创建补丁清单哈希文件:{manifestHashFilePath}");
|
||||
FileUtility.CreateFile(manifestHashFilePath, manifestHash);
|
||||
// 计算补丁清单文件的CRC32
|
||||
buildParametersContext.OutputPackageCRC = HashUtility.FileCRC32(manifestFileTempPath);
|
||||
|
||||
// 补丁清单文件重命名
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
string manifestFilePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
||||
EditorTools.FileMoveTo(manifestFileTempPath, manifestFilePath);
|
||||
|
||||
// 创建静态版本文件
|
||||
string staticVersionFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string staticVersion = resourceVersion.ToString();
|
||||
string staticVersionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.BuildPackage);
|
||||
string staticVersionFilePath = $"{pipelineOutputDirectory}/{staticVersionFileName}";
|
||||
BuildRunner.Log($"创建静态版本文件:{staticVersionFilePath}");
|
||||
FileUtility.CreateFile(staticVersionFilePath, staticVersion);
|
||||
FileUtility.CreateFile(staticVersionFilePath, buildParametersContext.OutputPackageCRC);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -111,7 +115,7 @@ namespace YooAsset.Editor
|
|||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
string filePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/{bundleInfo.BundleName}";
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
private string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
|
@ -120,7 +124,7 @@ namespace YooAsset.Editor
|
|||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000"; //8位
|
||||
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
string filePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/{bundleInfo.BundleName}";
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
private long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
|
@ -129,7 +133,7 @@ namespace YooAsset.Editor
|
|||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return 0;
|
||||
|
||||
string filePath = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
string filePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/{bundleInfo.BundleName}";
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,55 +19,51 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CopyPatchFiles(BuildParametersContext buildParameters)
|
||||
private void CopyPatchFiles(BuildParametersContext buildParametersContext)
|
||||
{
|
||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||
string packageDirectory = buildParameters.GetPackageDirectory();
|
||||
BuildRunner.Log($"开始拷贝补丁文件到补丁包目录:{packageDirectory}");
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildRunner.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
||||
|
||||
// 拷贝Report文件
|
||||
{
|
||||
string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.Parameters.BuildVersion);
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{reportFileName}";
|
||||
string destPath = $"{packageDirectory}/{reportFileName}";
|
||||
string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{reportFileName}";
|
||||
string destPath = $"{packageOutputDirectory}/{reportFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单哈希文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
||||
string destPath = $"{packageOutputDirectory}/{manifestFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝静态版本文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettings.VersionFileName}";
|
||||
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.BuildPackage);
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{versionFileName}";
|
||||
string destPath = $"{packageOutputDirectory}/{versionFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
if (buildParameters.Parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
// 拷贝构建日志
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/buildlogtep.json";
|
||||
string destPath = $"{packageDirectory}/buildlogtep.json";
|
||||
string sourcePath = $"{pipelineOutputDirectory}/buildlogtep.json";
|
||||
string destPath = $"{packageOutputDirectory}/buildlogtep.json";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝代码防裁剪配置
|
||||
if (buildParameters.Parameters.SBPParameters.WriteLinkXML)
|
||||
if (buildParameters.SBPParameters.WriteLinkXML)
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/link.xml";
|
||||
string destPath = $"{packageDirectory}/link.xml";
|
||||
string sourcePath = $"{pipelineOutputDirectory}/link.xml";
|
||||
string destPath = $"{packageOutputDirectory}/link.xml";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
@ -75,27 +71,27 @@ namespace YooAsset.Editor
|
|||
{
|
||||
// 拷贝UnityManifest序列化文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝UnityManifest文本文件
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
string destPath = $"{packageDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
int patchFileTotalCount = patchManifest.BundleList.Count;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||
string destPath = $"{packageDirectory}/{patchBundle.FileName}";
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||
string destPath = $"{packageOutputDirectory}/{patchBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
||||
}
|
||||
|
|
|
@ -24,9 +24,12 @@ namespace YooAsset.Editor
|
|||
BuildRunner.Info($"Build time consuming {buildSeconds} seconds.");
|
||||
}
|
||||
|
||||
private void CreateReportFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||
private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
BuildReport buildReport = new BuildReport();
|
||||
|
||||
// 概述信息
|
||||
|
@ -38,22 +41,22 @@ namespace YooAsset.Editor
|
|||
#endif
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = (int)buildParameters.GetBuildingSeconds();
|
||||
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.Parameters.BuildPipeline;
|
||||
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
|
||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
||||
buildReport.Summary.CopyBuildinTagFiles = buildParameters.Parameters.CopyBuildinTagFiles;
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
||||
buildReport.Summary.BuildSeconds = (int)buildParametersContext.GetBuildingSeconds();
|
||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||
buildReport.Summary.BuildPackage = buildParameters.BuildPackage;
|
||||
buildReport.Summary.BuildinTags = buildParameters.BuildinTags;
|
||||
buildReport.Summary.EnableAddressable = buildParameters.EnableAddressable;
|
||||
buildReport.Summary.CopyBuildinTagFiles = buildParameters.CopyBuildinTagFiles;
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
|
||||
// 构建参数
|
||||
buildReport.Summary.OutputNameStyle = buildParameters.Parameters.OutputNameStyle;
|
||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges;
|
||||
buildReport.Summary.OutputNameStyle = buildParameters.OutputNameStyle;
|
||||
buildReport.Summary.CompressOption = buildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = buildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.IgnoreTypeTreeChanges;
|
||||
|
||||
// 构建结果
|
||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||
|
@ -101,7 +104,8 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 删除旧文件
|
||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetReportFileName(buildParameters.Parameters.BuildVersion)}";
|
||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
string filePath = $"{pipelineOutputDirectory}/{fileName}";
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
private List<string> EncryptFiles(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||
private List<string> EncryptFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var encryptionServices = buildParameters.Parameters.EncryptionServices;
|
||||
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
||||
|
||||
// 加密资源列表
|
||||
List<string> encryptList = new List<string>();
|
||||
|
@ -57,6 +57,7 @@ namespace YooAsset.Editor
|
|||
return encryptList;
|
||||
|
||||
int progressValue = 0;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||
{
|
||||
if (encryptionServices.Check(bundleInfo.BundleName))
|
||||
|
@ -70,7 +71,7 @@ namespace YooAsset.Editor
|
|||
encryptList.Add(bundleInfo.BundleName);
|
||||
|
||||
// 注意:通过判断文件合法性,规避重复加密一个文件
|
||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
byte[] fileData = File.ReadAllBytes(filePath);
|
||||
if (EditorTools.CheckBundleFileValid(fileData))
|
||||
{
|
||||
|
|
|
@ -11,24 +11,18 @@ namespace YooAsset.Editor
|
|||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
buildParameters.BeginWatch();
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
buildParametersContext.BeginWatch();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
// 检测构建平台是否合法
|
||||
if (buildParameters.Parameters.BuildTarget == BuildTarget.NoTarget)
|
||||
// 检测构建参数合法性
|
||||
if (buildParameters.BuildTarget == BuildTarget.NoTarget)
|
||||
throw new Exception("请选择目标平台");
|
||||
if (string.IsNullOrEmpty(buildParameters.BuildPackage))
|
||||
throw new Exception("包裹名称不能为空");
|
||||
|
||||
// 检测构建版本是否合法
|
||||
if (buildParameters.Parameters.BuildVersion <= 0)
|
||||
throw new Exception("请先设置版本号");
|
||||
|
||||
// 检测输出目录是否为空
|
||||
if (string.IsNullOrEmpty(buildParameters.PipelineOutputDirectory))
|
||||
throw new Exception("输出目录不能为空");
|
||||
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
// 检测当前是否正在构建资源包
|
||||
if (BuildPipeline.isBuildingPlayer)
|
||||
|
@ -41,35 +35,10 @@ namespace YooAsset.Editor
|
|||
// 保存改动的资源
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
// 增量更新时候的必要检测
|
||||
if (buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
// 检测历史版本是否存在
|
||||
if (AssetBundleBuilderHelper.HasAnyPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot))
|
||||
{
|
||||
// 检测构建版本是否合法
|
||||
int maxPackageVersion = AssetBundleBuilderHelper.GetMaxPackageVersion(buildParameters.Parameters.BuildTarget, buildParameters.Parameters.OutputRoot);
|
||||
if (buildParameters.Parameters.BuildVersion <= maxPackageVersion)
|
||||
throw new Exception("构建版本不能小于历史版本");
|
||||
|
||||
// 检测补丁包是否已经存在
|
||||
string packageDirectory = buildParameters.GetPackageDirectory();
|
||||
if (Directory.Exists(packageDirectory))
|
||||
throw new Exception($"补丁包已经存在:{packageDirectory}");
|
||||
|
||||
// 检测内置资源分类标签是否一致
|
||||
var oldPatchManifest = AssetBundleBuilderHelper.GetOldPatchManifest(buildParameters.PipelineOutputDirectory);
|
||||
if (buildParameters.Parameters.BuildinTags != oldPatchManifest.BuildinTags)
|
||||
throw new Exception($"增量更新时内置资源标签必须一致:{buildParameters.Parameters.BuildinTags} != {oldPatchManifest.BuildinTags}");
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是强制重建
|
||||
if (buildMode == EBuildMode.ForceRebuild)
|
||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
{
|
||||
// 删除平台总目录
|
||||
string platformDirectory = $"{buildParameters.Parameters.OutputRoot}/{buildParameters.Parameters.BuildTarget}";
|
||||
string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.BuildPackage}/{buildParameters.BuildTarget}";
|
||||
if (EditorTools.DeleteDirectory(platformDirectory))
|
||||
{
|
||||
BuildRunner.Log($"删除平台总目录:{platformDirectory}");
|
||||
|
@ -77,9 +46,10 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 如果输出目录不存在
|
||||
if (EditorTools.CreateDirectory(buildParameters.PipelineOutputDirectory))
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||
{
|
||||
BuildRunner.Log($"创建输出目录:{buildParameters.PipelineOutputDirectory}");
|
||||
BuildRunner.Log($"创建输出目录:{pipelineOutputDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
||||
|
||||
|
@ -63,13 +63,14 @@ namespace YooAsset.Editor
|
|||
|
||||
// 4. 验证Asset
|
||||
bool isPass = true;
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
int progressValue = 0;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var buildedBundle in buildedBundles)
|
||||
{
|
||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{buildedBundle}";
|
||||
string filePath = $"{pipelineOutputDirectory}/{buildedBundle}";
|
||||
string[] buildedAssetPaths = GetAssetBundleAllAssets(filePath);
|
||||
string[] mapAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
|
||||
if (mapAssetPaths.Length != buildedAssetPaths.Length)
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace YooAsset.Editor
|
|||
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
||||
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
|
||||
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
||||
_items.Add(new ItemWrapper("构建版本", $"{buildReport.Summary.BuildVersion}"));
|
||||
_items.Add(new ItemWrapper("构建包裹", $"{buildReport.Summary.BuildPackage}"));
|
||||
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
|
||||
|
||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
||||
|
|
|
@ -353,6 +353,9 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public static void FileMoveTo(string filePath, string destPath)
|
||||
{
|
||||
if (File.Exists(destPath))
|
||||
File.Delete(destPath);
|
||||
|
||||
FileInfo fileInfo = new FileInfo(filePath);
|
||||
fileInfo.MoveTo(destPath);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue