update editor

1. 编辑器界面支持本地化配置。
2. 资源构建过程中的异常输出增加错误码提示。
3. 修复了资源构建界面乱码问题。
4. 修复了自动收集着色器对依赖资源无效的问题。
This commit is contained in:
hevinci
2023-10-13 12:06:20 +08:00
parent db889366ac
commit 0c70f27560
66 changed files with 623 additions and 268 deletions

View File

@@ -7,7 +7,6 @@ using UnityEngine;
namespace YooAsset.Editor
{
[TaskAttribute("资源构建内容打包")]
public class TaskBuilding_BBP : IBuildTask
{
public class BuildResultContext : IContextObject
@@ -29,22 +28,26 @@ namespace YooAsset.Editor
// 开始构建
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
if (buildResults == null)
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
if (unityManifest == null)
{
throw new Exception("构建过程中发生错误!");
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
throw new Exception(message);
}
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
{
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
{
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
throw new Exception(message);
}
}
BuildLogger.Log("Unity引擎打包成功!");
BuildLogger.Log("UnityEngine build success !");
BuildResultContext buildResultContext = new BuildResultContext();
buildResultContext.UnityManifest = buildResults;
buildResultContext.UnityManifest = unityManifest;
context.SetContextObject(buildResultContext);
}
}

View File

@@ -6,7 +6,6 @@ using UnityEngine;
namespace YooAsset.Editor
{
[TaskAttribute("拷贝内置文件")]
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
{
void IBuildTask.Run(BuildContext context)

View File

@@ -5,7 +5,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
[TaskAttribute("创建清单文件")]
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
{
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
[TaskAttribute("制作包裹")]
public class TaskCreatePackage_BBP : IBuildTask
{
void IBuildTask.Run(BuildContext context)
@@ -13,18 +12,18 @@ namespace YooAsset.Editor
var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
{
CopyPackageFiles(buildParameters, buildMapContext);
CreatePackageCatalog(buildParameters, buildMapContext);
}
}
/// <summary>
/// 拷贝补丁文件到补丁包目录
/// </summary>
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
{
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
// 拷贝UnityManifest序列化文件
{
@@ -46,7 +45,7 @@ namespace YooAsset.Editor
foreach (var bundleInfo in buildMapContext.Collection)
{
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount);
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
}
EditorTools.ClearProgressBar();
}

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor
{
[TaskAttribute("创建构建报告文件")]
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
{
void IBuildTask.Run(BuildContext context)

View File

@@ -6,7 +6,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
[TaskAttribute("资源包加密")]
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
{
void IBuildTask.Run(BuildContext context)

View File

@@ -7,7 +7,6 @@ using UnityEditor;
namespace YooAsset.Editor
{
[TaskAttribute("获取资源构建内容")]
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
{
void IBuildTask.Run(BuildContext context)

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor
{
[TaskAttribute("资源构建准备工作")]
public class TaskPrepare_BBP : IBuildTask
{
void IBuildTask.Run(BuildContext context)
@@ -22,7 +21,8 @@ namespace YooAsset.Editor
#if UNITY_2021_3_OR_NEWER
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
{
BuildLogger.Warning("Unity2021版本开始内置构建管线不再维护推荐使用可编程构建管线SBP");
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
BuildLogger.Warning(warning);
}
#endif
}

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor
{
[TaskAttribute("更新资源包信息")]
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
{
void IBuildTask.Run(BuildContext context)
@@ -28,9 +27,14 @@ namespace YooAsset.Editor
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
if (hash.isValid)
{
return hash.ToString();
}
else
throw new Exception($"Not found bundle hash in build result : {bundleInfo.BundleName}");
{
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
throw new Exception(message);
}
}
}
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
@@ -46,9 +50,14 @@ namespace YooAsset.Editor
{
string filePath = bundleInfo.BuildOutputFilePath;
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
{
return crc;
}
else
throw new Exception($"Not found bundle crc in build result : {bundleInfo.BundleName}");
{
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
throw new Exception(message);
}
}
}
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)

View File

@@ -8,7 +8,6 @@ using UnityEngine;
namespace YooAsset.Editor
{
[TaskAttribute("验证构建结果")]
public class TaskVerifyBuildResult_BBP : IBuildTask
{
void IBuildTask.Run(BuildContext context)
@@ -46,9 +45,12 @@ namespace YooAsset.Editor
{
foreach (var exceptBundle in exceptBundleList1)
{
BuildLogger.Warning($"差异资源包: {exceptBundle}");
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
BuildLogger.Warning(warning);
}
throw new System.Exception("存在差异资源包!请查看警告信息!");
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
throw new Exception(exception);
}
// 3. 验证Bundle
@@ -57,12 +59,15 @@ namespace YooAsset.Editor
{
foreach (var exceptBundle in exceptBundleList2)
{
BuildLogger.Warning($"差异资源包: {exceptBundle}");
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
BuildLogger.Warning(warning);
}
throw new System.Exception("存在差异资源包!请查看警告信息!");
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
throw new Exception(exception);
}
BuildLogger.Log("构建结果验证成功!");
BuildLogger.Log("Build results verify success!");
}
}
}

View File

@@ -22,15 +22,15 @@ namespace YooAsset.Editor
{
List<IBuildTask> pipeline = new List<IBuildTask>
{
new TaskPrepare_BBP(), //前期准备工作
new TaskGetBuildMap_BBP(), //获取构建列表
new TaskBuilding_BBP(), //开始执行构建
new TaskVerifyBuildResult_BBP(), //验证构建结果
new TaskUpdateBundleInfo_BBP(), //更新资源包信息
new TaskCreateManifest_BBP(), //创建清单文件
new TaskCreateReport_BBP(), //创建报告文件
new TaskCreatePackage_BBP(), //制作包裹
new TaskCopyBuildinFiles_BBP(), //拷贝内置文件
new TaskPrepare_BBP(),
new TaskGetBuildMap_BBP(),
new TaskBuilding_BBP(),
new TaskVerifyBuildResult_BBP(),
new TaskUpdateBundleInfo_BBP(),
new TaskCreateManifest_BBP(),
new TaskCreateReport_BBP(),
new TaskCreatePackage_BBP(),
new TaskCopyBuildinFiles_BBP(),
};
return pipeline;
}