YooAsset/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs

58 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace YooAsset.Editor
{
public class BuildRunner
{
public static bool EnableLog = true;
/// <summary>
/// 执行构建流程
/// </summary>
/// <returns>如果成功返回TRUE否则返回FALSE</returns>
public static bool Run(List<IBuildTask> pipeline, BuildContext context)
{
if (pipeline == null)
throw new ArgumentNullException("pipeline");
if (context == null)
throw new ArgumentNullException("context");
bool succeed = true;
for (int i = 0; i < pipeline.Count; i++)
{
IBuildTask task = pipeline[i];
try
{
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
Log($"---------------------------------------->{taskAttribute.Desc}");
task.Run(context);
}
catch (Exception e)
{
Debug.LogError($"Build task {task.GetType().Name} failed !");
Debug.LogError($"Build error : {e}");
succeed = false;
break;
}
}
// 返回运行结果
return succeed;
}
/// <summary>
/// 普通日志输出
/// </summary>
public static void Log(string info)
{
if (EnableLog)
{
UnityEngine.Debug.Log(info);
}
}
}
}