Update AssetBundleBuilder

增加资源构建结果返回信息
pull/31/head
hevinci 2022-07-31 22:41:24 +08:00
parent 75910b7558
commit 9c67461dbc
6 changed files with 56 additions and 14 deletions

View File

@ -13,7 +13,7 @@ namespace YooAsset.Editor
/// <summary>
/// 开始构建
/// </summary>
public bool Run(BuildParameters buildParameters)
public BuildResult Run(BuildParameters buildParameters)
{
// 清空旧数据
_buildContext.ClearAllContext();
@ -77,12 +77,18 @@ namespace YooAsset.Editor
}
// 执行构建流程
bool succeed = BuildRunner.Run(pipeline, _buildContext);
if (succeed)
var buildResult = BuildRunner.Run(pipeline, _buildContext);
if (buildResult.Success)
{
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
}
else
{
Debug.LogWarning($"{buildParameters.BuildMode} pipeline build failed !");
return succeed;
Debug.LogError($"Build task failed : {buildResult.FailedTask}");
Debug.LogError($"Build task error : {buildResult.FailedInfo}");
}
return buildResult;
}
}
}

View File

@ -237,8 +237,8 @@ namespace YooAsset.Editor
}
var builder = new AssetBundleBuilder();
bool succeed = builder.Run(buildParameters);
if (succeed)
var buildResult = builder.Run(buildParameters);
if (buildResult.Success)
{
EditorUtility.RevealInFinder($"{buildParameters.OutputRoot}/{buildParameters.BuildTarget}/{buildParameters.BuildVersion}");
}

View File

@ -20,8 +20,8 @@ namespace YooAsset.Editor
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
AssetBundleBuilder builder = new AssetBundleBuilder();
bool buildResult = builder.Run(buildParameters);
if (buildResult)
var buildResult = builder.Run(buildParameters);
if (buildResult.Success)
{
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildTarget);
_manifestFilePath = $"{pipelineOutputDirectory}_{EBuildMode.SimulateBuild}/{YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildVersion)}";

View File

@ -0,0 +1,24 @@

namespace YooAsset.Editor
{
/// <summary>
/// 构建结果
/// </summary>
public class BuildResult
{
/// <summary>
/// 构建是否成功
/// </summary>
public bool Success;
/// <summary>
/// 构建失败的任务
/// </summary>
public string FailedTask;
/// <summary>
/// 构建失败的信息
/// </summary>
public string FailedInfo;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0855c4b5eaa26942bd7ad177fe3c288
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -14,14 +14,15 @@ namespace YooAsset.Editor
/// 执行构建流程
/// </summary>
/// <returns>如果成功返回TRUE否则返回FALSE</returns>
public static bool Run(List<IBuildTask> pipeline, BuildContext context)
public static BuildResult Run(List<IBuildTask> pipeline, BuildContext context)
{
if (pipeline == null)
throw new ArgumentNullException("pipeline");
if (context == null)
throw new ArgumentNullException("context");
bool succeed = true;
BuildResult buildResult = new BuildResult();
buildResult.Success = true;
for (int i = 0; i < pipeline.Count; i++)
{
IBuildTask task = pipeline[i];
@ -33,15 +34,15 @@ namespace YooAsset.Editor
}
catch (Exception e)
{
Debug.LogError($"Build task {task.GetType().Name} failed !");
Debug.LogError($"Build error : {e}");
succeed = false;
buildResult.FailedTask = task.GetType().Name;
buildResult.FailedInfo = e.ToString();
buildResult.Success = false;
break;
}
}
// 返回运行结果
return succeed;
return buildResult;
}
/// <summary>