diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
index 7d7a348..eb4b2f5 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
@@ -13,17 +13,18 @@ namespace YooAsset.Editor
private readonly BuildContext _buildContext = new BuildContext();
///
- /// 开始构建
+ /// 构建资源包
///
- public BuildResult Run(BuildParameters buildParameters)
+ public BuildResult Run(BuildParameters buildParameters, List buildPipeline)
{
- // 清空旧数据
- _buildContext.ClearAllContext();
-
// 检测构建参数是否为空
if (buildParameters == null)
throw new Exception($"{nameof(buildParameters)} is null !");
+ // 检测构建参数是否为空
+ if (buildPipeline.Count == 0)
+ throw new Exception($"Build pipeline is empty !");
+
// 检测可编程构建管线参数
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
{
@@ -37,6 +38,9 @@ namespace YooAsset.Editor
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
}
+ // 清空旧数据
+ _buildContext.ClearAllContext();
+
// 构建参数
var buildParametersContext = new BuildParametersContext(buildParameters);
_buildContext.SetContextObject(buildParametersContext);
@@ -45,8 +49,7 @@ namespace YooAsset.Editor
BuildLogger.InitLogger(buildParameters.EnableLog);
// 执行构建流程
- var pipeline = GetBuildTasks(buildParameters.BuildPipeline);
- var buildResult = BuildRunner.Run(pipeline, _buildContext);
+ var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
if (buildResult.Success)
{
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
@@ -62,13 +65,23 @@ namespace YooAsset.Editor
return buildResult;
}
- private List GetBuildTasks(EBuildPipeline buildPipeline)
+ ///
+ /// 构建资源包
+ ///
+ public BuildResult Run(BuildParameters buildParameters)
+ {
+ var buildPipeline = GetDefaultBuildPipeline(buildParameters.BuildPipeline);
+ return Run(buildParameters, buildPipeline);
+ }
+
+ ///
+ /// 获取默认的构建流程
+ ///
+ private List GetDefaultBuildPipeline(EBuildPipeline buildPipeline)
{
// 获取任务节点的属性集合
- List attrList = new List();
if (buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
{
- /*
List pipeline = new List
{
new TaskPrepare(), //前期准备工作
@@ -83,23 +96,10 @@ namespace YooAsset.Editor
new TaskCreatePackage(), //制作包裹
new TaskCopyBuildinFiles(), //拷贝内置文件
};
- */
-
- var classTypes = EditorTools.GetAssignableTypes(typeof(IBuildTask));
- foreach (var classType in classTypes)
- {
- var attribute = classType.GetCustomAttribute();
- if (attribute == null)
- throw new Exception($"Not found {nameof(TaskAttribute)} int type : {classType.FullName}");
-
- attribute.ClassType = classType;
- if (attribute.Pipeline == ETaskPipeline.AllPipeline || attribute.Pipeline == ETaskPipeline.BuiltinBuildPipeline)
- attrList.Add(attribute);
- }
+ return pipeline;
}
else if (buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
{
- /*
List pipeline = new List
{
new TaskPrepare(), //前期准备工作
@@ -114,42 +114,12 @@ namespace YooAsset.Editor
new TaskCreatePackage(), //制作补丁包
new TaskCopyBuildinFiles(), //拷贝内置文件
};
- */
-
- var classTypes = EditorTools.GetAssignableTypes(typeof(IBuildTask));
- foreach (var classType in classTypes)
- {
- var attribute = classType.GetCustomAttribute();
- if (attribute == null)
- throw new Exception($"Not found {nameof(TaskAttribute)} int type : {classType.FullName}");
-
- attribute.ClassType = classType;
- if (attribute.Pipeline == ETaskPipeline.AllPipeline || attribute.Pipeline == ETaskPipeline.ScriptableBuildPipeline)
- attrList.Add(attribute);
- }
+ return pipeline;
}
else
{
throw new NotImplementedException();
}
-
- // 对任务节点进行排序
- attrList.Sort((a, b) =>
- {
- if (a.TaskOrder > b.TaskOrder) { return 1; }
- else if (a.TaskOrder < b.TaskOrder) { return -1; }
- else { return 0; }
- });
-
- // 创建任务节点实例
- List pipeline = new List(attrList.Count);
- foreach (var taskAttr in attrList)
- {
- var task = Activator.CreateInstance(taskAttr.ClassType) as IBuildTask;
- pipeline.Add(task);
- }
-
- return pipeline;
}
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/ETaskPipeline.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/ETaskPipeline.cs
deleted file mode 100644
index f90df01..0000000
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/ETaskPipeline.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-
-namespace YooAsset.Editor
-{
- public enum ETaskPipeline
- {
- ///
- /// 所有的构建管线
- ///
- AllPipeline,
-
- ///
- /// 内置构建管线
- ///
- BuiltinBuildPipeline,
-
- ///
- /// 可编程构建管线
- ///
- ScriptableBuildPipeline,
- }
-}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/ETaskPipeline.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/ETaskPipeline.cs.meta
deleted file mode 100644
index ccabb5f..0000000
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/ETaskPipeline.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 32477ef3a448a9144aa1574a052fe54e
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/TaskAttribute.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/TaskAttribute.cs
index 1b970d4..a877b65 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/TaskAttribute.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildSystem/TaskAttribute.cs
@@ -5,28 +5,13 @@ namespace YooAsset.Editor
[AttributeUsage(AttributeTargets.Class)]
public class TaskAttribute : Attribute
{
- ///
- /// 任务所属的构建流水线
- ///
- public ETaskPipeline Pipeline;
-
- ///
- /// 执行顺序
- ///
- public int TaskOrder;
-
///
/// 任务说明
///
public string TaskDesc;
- // 关联的任务类
- public Type ClassType { set; get; }
-
- public TaskAttribute(ETaskPipeline pipeline, int taskOrder, string taskDesc)
+ public TaskAttribute(string taskDesc)
{
- Pipeline = pipeline;
- TaskOrder = taskOrder;
TaskDesc = taskDesc;
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
index fdf7248..da267bd 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
@@ -7,7 +7,7 @@ using UnityEngine;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.BuiltinBuildPipeline, 300, "资源构建内容打包")]
+ [TaskAttribute("资源构建内容打包")]
public class TaskBuilding : IBuildTask
{
public class BuildResultContext : IContextObject
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
index a45feb8..6c0f294 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
@@ -9,7 +9,7 @@ using UnityEditor.Build.Pipeline.Tasks;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.ScriptableBuildPipeline, 300, "资源构建内容打包")]
+ [TaskAttribute("资源构建内容打包")]
public class TaskBuilding_SBP : IBuildTask
{
public class BuildResultContext : IContextObject
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs
index 3b54adb..4f9d1e5 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs
@@ -6,7 +6,7 @@ using UnityEngine;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.AllPipeline, 1100, "拷贝内置文件到流目录")]
+ [TaskAttribute("拷贝内置文件到流目录")]
public class TaskCopyBuildinFiles : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs
index 1922176..661af52 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs
@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.AllPipeline, 400, "拷贝原生文件")]
+ [TaskAttribute("拷贝原生文件")]
public class TaskCopyRawFile : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs
index 049aac3..a4a10da 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
internal PackageManifest Manifest;
}
- [TaskAttribute(ETaskPipeline.AllPipeline, 800, "创建清单文件")]
+ [TaskAttribute("创建清单文件")]
public class TaskCreateManifest : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs
index 6d43997..4f891bb 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.AllPipeline, 1000, "制作包裹")]
+ [TaskAttribute("制作包裹")]
public class TaskCreatePackage : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
index 9a86763..8671e41 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
@@ -6,7 +6,7 @@ using UnityEditor;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.AllPipeline, 900, "创建构建报告文件")]
+ [TaskAttribute("创建构建报告文件")]
public class TaskCreateReport : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
index c0a2c76..4ca3832 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
@@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.AllPipeline, 600, "资源包加密")]
+ [TaskAttribute("资源包加密")]
public class TaskEncryption : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
index ff93168..e9cba15 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
@@ -7,7 +7,7 @@ using UnityEditor;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.AllPipeline, 200, "获取资源构建内容")]
+ [TaskAttribute("获取资源构建内容")]
public class TaskGetBuildMap : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs
index 8a2b19f..46a8120 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs
@@ -6,7 +6,7 @@ using UnityEditor;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.AllPipeline, 100, "资源构建准备工作")]
+ [TaskAttribute("资源构建准备工作")]
public class TaskPrepare : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs
index 75976b0..4881a51 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs
@@ -6,7 +6,7 @@ using UnityEditor;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.AllPipeline, 700, "更新资源包信息")]
+ [TaskAttribute("更新资源包信息")]
public class TaskUpdateBundleInfo : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
index f113e4a..e3ffbbf 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
@@ -8,7 +8,7 @@ using UnityEngine;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.BuiltinBuildPipeline, 500, "验证构建结果")]
+ [TaskAttribute("验证构建结果")]
public class TaskVerifyBuildResult : IBuildTask
{
void IBuildTask.Run(BuildContext context)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
index 33c8ff2..b4ec42a 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
@@ -9,7 +9,7 @@ using UnityEditor.Build.Pipeline.Interfaces;
namespace YooAsset.Editor
{
- [TaskAttribute(ETaskPipeline.ScriptableBuildPipeline, 500, "验证构建结果")]
+ [TaskAttribute("验证构建结果")]
public class TaskVerifyBuildResult_SBP : IBuildTask
{
void IBuildTask.Run(BuildContext context)