update asset bundle builder
parent
93d7c34454
commit
b330d26b4f
|
@ -39,12 +39,6 @@ namespace YooAsset.Editor
|
||||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||||
_buildContext.SetContextObject(buildParametersContext);
|
_buildContext.SetContextObject(buildParametersContext);
|
||||||
|
|
||||||
// 是否显示LOG
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
|
||||||
BuildLogger.EnableLog = false;
|
|
||||||
else
|
|
||||||
BuildLogger.EnableLog = true;
|
|
||||||
|
|
||||||
// 创建构建节点
|
// 创建构建节点
|
||||||
List<IBuildTask> pipeline;
|
List<IBuildTask> pipeline;
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
|
@ -86,19 +80,23 @@ namespace YooAsset.Editor
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化日志
|
||||||
|
BuildLogger.InitLogger(buildParameters.EnableLog);
|
||||||
|
|
||||||
// 执行构建流程
|
// 执行构建流程
|
||||||
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
BuildLogger.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"{buildParameters.BuildMode} pipeline build failed !");
|
BuildLogger.Warning($"{buildParameters.BuildMode} pipeline build failed !");
|
||||||
Debug.LogError($"Build task failed : {buildResult.FailedTask}");
|
BuildLogger.Error($"Build task failed : {buildResult.FailedTask}");
|
||||||
Debug.LogError($"Build task error : {buildResult.FailedInfo}");
|
BuildLogger.Error($"Build task error : {buildResult.FailedInfo}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace YooAsset.Editor
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
buildParameters.PackageVersion = "Simulate";
|
buildParameters.PackageVersion = "Simulate";
|
||||||
|
buildParameters.EnableLog = false;
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
var buildResult = builder.Run(buildParameters);
|
var buildResult = builder.Run(buildParameters);
|
||||||
|
|
|
@ -67,6 +67,11 @@ namespace YooAsset.Editor
|
||||||
public string PackageVersion;
|
public string PackageVersion;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示普通日志
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableLog = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class BuildLogger
|
public static class BuildLogger
|
||||||
{
|
{
|
||||||
/// <summary>
|
private static bool _enableLog = true;
|
||||||
/// 是否启用LOG
|
|
||||||
/// </summary>
|
|
||||||
public static bool EnableLog = true;
|
|
||||||
|
|
||||||
/// <summary>
|
public static void InitLogger(bool enableLog)
|
||||||
/// 日志输出
|
|
||||||
/// </summary>
|
|
||||||
public static void Log(string info)
|
|
||||||
{
|
{
|
||||||
if (EnableLog)
|
_enableLog = enableLog;
|
||||||
{
|
|
||||||
UnityEngine.Debug.Log(info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public static void Log(string message)
|
||||||
/// 日志输出
|
|
||||||
/// </summary>
|
|
||||||
public static void Info(string info)
|
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log(info);
|
if (_enableLog)
|
||||||
|
{
|
||||||
|
Debug.Log(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void Warning(string message)
|
||||||
|
{
|
||||||
|
Debug.LogWarning(message);
|
||||||
|
}
|
||||||
|
public static void Error(string message)
|
||||||
|
{
|
||||||
|
Debug.LogError(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -47,7 +47,7 @@ namespace YooAsset.Editor
|
||||||
// 注意:原生文件不支持加密
|
// 注意:原生文件不支持加密
|
||||||
if (bundleInfo.IsRawFile)
|
if (bundleInfo.IsRawFile)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"Encryption not support raw file : {bundleInfo.BundleName}");
|
BuildLogger.Warning($"Encryption not support raw file : {bundleInfo.BundleName}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
@ -76,16 +76,16 @@ namespace YooAsset.Editor
|
||||||
string[] mapAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
|
string[] mapAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
|
||||||
if (mapAssetPaths.Length != buildedAssetPaths.Length)
|
if (mapAssetPaths.Length != buildedAssetPaths.Length)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"构建的Bundle文件内的资源对象数量和预期不匹配 : {buildedBundle}");
|
BuildLogger.Warning($"构建的Bundle文件内的资源对象数量和预期不匹配 : {buildedBundle}");
|
||||||
var exceptAssetList1 = mapAssetPaths.Except(buildedAssetPaths).ToList();
|
var exceptAssetList1 = mapAssetPaths.Except(buildedAssetPaths).ToList();
|
||||||
foreach (var excpetAsset in exceptAssetList1)
|
foreach (var excpetAsset in exceptAssetList1)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"构建失败的资源对象路径为 : {excpetAsset}");
|
BuildLogger.Warning($"构建失败的资源对象路径为 : {excpetAsset}");
|
||||||
}
|
}
|
||||||
var exceptAssetList2 = buildedAssetPaths.Except(mapAssetPaths).ToList();
|
var exceptAssetList2 = buildedAssetPaths.Except(mapAssetPaths).ToList();
|
||||||
foreach (var excpetAsset in exceptAssetList2)
|
foreach (var excpetAsset in exceptAssetList2)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"构建失败的资源对象路径为 : {excpetAsset}");
|
BuildLogger.Warning($"构建失败的资源对象路径为 : {excpetAsset}");
|
||||||
}
|
}
|
||||||
isPass = false;
|
isPass = false;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"差异资源包: {exceptBundle}");
|
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue