From 9c67461dbc460f95cd07077c7505a500217642c7 Mon Sep 17 00:00:00 2001 From: hevinci Date: Sun, 31 Jul 2022 22:41:24 +0800 Subject: [PATCH] Update AssetBundleBuilder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加资源构建结果返回信息 --- .../AssetBundleBuilder/AssetBundleBuilder.cs | 14 +++++++---- .../AssetBundleBuilderWindow.cs | 4 ++-- .../AssetBundleSimulateBuilder.cs | 4 ++-- .../BuildSystem/BuildResult.cs | 24 +++++++++++++++++++ .../BuildSystem/BuildResult.cs.meta | 11 +++++++++ .../BuildSystem/BuildRunner.cs | 13 +++++----- 6 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs create mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs index 8fbbda5..2136ce5 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs @@ -13,7 +13,7 @@ namespace YooAsset.Editor /// /// 开始构建 /// - 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; } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs index 2c8d6cd..3b29c54 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs @@ -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}"); } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs index 191c422..ca027d2 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs @@ -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)}"; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs new file mode 100644 index 0000000..619db33 --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs @@ -0,0 +1,24 @@ + +namespace YooAsset.Editor +{ + /// + /// 构建结果 + /// + public class BuildResult + { + /// + /// 构建是否成功 + /// + public bool Success; + + /// + /// 构建失败的任务 + /// + public string FailedTask; + + /// + /// 构建失败的信息 + /// + public string FailedInfo; + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs.meta new file mode 100644 index 0000000..a8ebe2b --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e0855c4b5eaa26942bd7ad177fe3c288 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs index 1d634e2..9fb013c 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs @@ -14,14 +14,15 @@ namespace YooAsset.Editor /// 执行构建流程 /// /// 如果成功返回TRUE,否则返回FALSE - public static bool Run(List pipeline, BuildContext context) + public static BuildResult Run(List 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; } ///