diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
index d39c761..fe94142 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs
@@ -8,96 +8,6 @@ namespace YooAsset.Editor
{
public class AssetBundleBuilder
{
- public class BuildParametersContext : IContextObject
- {
- private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
-
- ///
- /// 构建参数
- ///
- public BuildParameters Parameters { private set; get; }
-
- ///
- /// 构建管线的输出目录
- ///
- public string PipelineOutputDirectory { private set; get; }
-
-
- public BuildParametersContext(BuildParameters parameters)
- {
- Parameters = parameters;
-
- PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
- if (parameters.BuildMode == EBuildMode.DryRunBuild)
- PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
- else if (parameters.BuildMode == EBuildMode.SimulateBuild)
- PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
- }
-
- ///
- /// 获取本次构建的补丁目录
- ///
- public string GetPackageDirectory()
- {
- return $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.BuildVersion}";
- }
-
- ///
- /// 获取构建选项
- ///
- public BuildAssetBundleOptions GetPipelineBuildOptions()
- {
- // For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
- // 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
-
- BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
- opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
-
- if (Parameters.BuildMode == EBuildMode.SimulateBuild)
- throw new Exception("Should never get here !");
-
- if (Parameters.BuildMode == EBuildMode.DryRunBuild)
- {
- opt |= BuildAssetBundleOptions.DryRunBuild;
- return opt;
- }
-
- if (Parameters.CompressOption == ECompressOption.Uncompressed)
- opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
- else if (Parameters.CompressOption == ECompressOption.LZ4)
- opt |= BuildAssetBundleOptions.ChunkBasedCompression;
-
- if (Parameters.BuildMode == EBuildMode.ForceRebuild)
- opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
- if (Parameters.DisableWriteTypeTree)
- opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
- if (Parameters.IgnoreTypeTreeChanges)
- opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
-
- opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
- opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
-
- return opt;
- }
-
- ///
- /// 获取构建的耗时(单位:秒)
- ///
- public float GetBuildingSeconds()
- {
- float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
- return seconds;
- }
- public void BeginWatch()
- {
- _buildWatch.Start();
- }
- public void StopWatch()
- {
- _buildWatch.Stop();
- }
- }
-
private readonly BuildContext _buildContext = new BuildContext();
///
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs
new file mode 100644
index 0000000..6e190ac
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEditor;
+
+namespace YooAsset.Editor
+{
+ public class BuildParametersContext : IContextObject
+ {
+ private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
+
+ ///
+ /// 构建参数
+ ///
+ public BuildParameters Parameters { private set; get; }
+
+ ///
+ /// 构建管线的输出目录
+ ///
+ public string PipelineOutputDirectory { private set; get; }
+
+
+ public BuildParametersContext(BuildParameters parameters)
+ {
+ Parameters = parameters;
+
+ PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
+ if (parameters.BuildMode == EBuildMode.DryRunBuild)
+ PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
+ else if (parameters.BuildMode == EBuildMode.SimulateBuild)
+ PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
+ }
+
+ ///
+ /// 获取本次构建的补丁目录
+ ///
+ public string GetPackageDirectory()
+ {
+ return $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.BuildVersion}";
+ }
+
+ ///
+ /// 获取构建选项
+ ///
+ public BuildAssetBundleOptions GetPipelineBuildOptions()
+ {
+ // For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
+ // 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
+
+ BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
+ opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
+
+ if (Parameters.BuildMode == EBuildMode.SimulateBuild)
+ throw new Exception("Should never get here !");
+
+ if (Parameters.BuildMode == EBuildMode.DryRunBuild)
+ {
+ opt |= BuildAssetBundleOptions.DryRunBuild;
+ return opt;
+ }
+
+ if (Parameters.CompressOption == ECompressOption.Uncompressed)
+ opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
+ else if (Parameters.CompressOption == ECompressOption.LZ4)
+ opt |= BuildAssetBundleOptions.ChunkBasedCompression;
+
+ if (Parameters.BuildMode == EBuildMode.ForceRebuild)
+ opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
+ if (Parameters.DisableWriteTypeTree)
+ opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
+ if (Parameters.IgnoreTypeTreeChanges)
+ opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
+
+ opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
+ opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
+
+ return opt;
+ }
+
+ ///
+ /// 获取构建的耗时(单位:秒)
+ ///
+ public float GetBuildingSeconds()
+ {
+ float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
+ return seconds;
+ }
+ public void BeginWatch()
+ {
+ _buildWatch.Start();
+ }
+ public void StopWatch()
+ {
+ _buildWatch.Stop();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs.meta
new file mode 100644
index 0000000..665fc41
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParametersContext.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b84510feab7cbe44a9b6d8ef0b3f559c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
index ed31245..b5e06eb 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs
@@ -18,7 +18,7 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context)
{
- var buildParametersContext = context.GetContextObject();
+ var buildParametersContext = context.GetContextObject();
var buildMapContext = context.GetContextObject();
// 模拟构建模式下跳过引擎构建
@@ -46,7 +46,7 @@ namespace YooAsset.Editor
///
/// 拷贝原生文件
///
- private void CopyRawBundle(BuildMapContext buildMapContext, AssetBundleBuilder.BuildParametersContext buildParametersContext)
+ private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
{
foreach (var bundleInfo in buildMapContext.BundleInfos)
{
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs
index 1410deb..c0e8d96 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context)
{
// 注意:我们只有在强制重建的时候才会拷贝
- var buildParameters = context.GetContextObject();
+ var buildParameters = context.GetContextObject();
if (buildParameters.Parameters.CopyBuildinTagFiles)
{
// 清空流目录
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
index c54db18..6018224 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
@@ -10,17 +10,17 @@ namespace YooAsset.Editor
{
void IBuildTask.Run(BuildContext context)
{
- var buildParameters = context.GetContextObject();
- var encryptionContext = context.GetContextObject();
+ var buildParameters = context.GetContextObject();
var buildMapContext = context.GetContextObject();
+ var encryptionContext = context.GetContextObject();
CreatePatchManifestFile(buildParameters, buildMapContext, encryptionContext);
}
///
/// 创建补丁清单文件到输出目录
///
- private void CreatePatchManifestFile(AssetBundleBuilder.BuildParametersContext buildParameters,
- BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext)
+ private void CreatePatchManifestFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext,
+ TaskEncryption.EncryptionContext encryptionContext)
{
int resourceVersion = buildParameters.Parameters.BuildVersion;
@@ -53,8 +53,8 @@ namespace YooAsset.Editor
///
/// 获取资源包列表
///
- private List GetAllPatchBundle(AssetBundleBuilder.BuildParametersContext buildParameters,
- BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext)
+ private List GetAllPatchBundle(BuildParametersContext buildParameters, BuildMapContext buildMapContext,
+ TaskEncryption.EncryptionContext encryptionContext)
{
List result = new List(1000);
@@ -124,8 +124,7 @@ namespace YooAsset.Editor
///
/// 获取资源列表
///
- private List GetAllPatchAsset(AssetBundleBuilder.BuildParametersContext buildParameters,
- BuildMapContext buildMapContext, PatchManifest patchManifest)
+ private List GetAllPatchAsset(BuildParametersContext buildParameters, BuildMapContext buildMapContext, PatchManifest patchManifest)
{
List result = new List(1000);
foreach (var bundleInfo in buildMapContext.BundleInfos)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs
index 7cdaad8..a9721f3 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs
@@ -8,7 +8,7 @@ namespace YooAsset.Editor
{
void IBuildTask.Run(BuildContext context)
{
- var buildParameters = context.GetContextObject();
+ var buildParameters = context.GetContextObject();
var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
{
@@ -19,7 +19,7 @@ namespace YooAsset.Editor
///
/// 拷贝补丁文件到补丁包目录
///
- private void CopyPatchFiles(AssetBundleBuilder.BuildParametersContext buildParameters)
+ private void CopyPatchFiles(BuildParametersContext buildParameters)
{
int resourceVersion = buildParameters.Parameters.BuildVersion;
string packageDirectory = buildParameters.GetPackageDirectory();
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
index fc5bd1f..919732d 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
{
void IBuildTask.Run(BuildContext context)
{
- var buildParameters = context.GetContextObject();
+ var buildParameters = context.GetContextObject();
var buildMapContext = context.GetContextObject();
buildParameters.StopWatch();
@@ -26,7 +26,7 @@ namespace YooAsset.Editor
}
}
- private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
+ private void CreateReportFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
{
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
BuildReport buildReport = new BuildReport();
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
index ec746a9..eb006d9 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskEncryption.cs
@@ -24,7 +24,7 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context)
{
- var buildParameters = context.GetContextObject();
+ var buildParameters = context.GetContextObject();
var buildMapContext = context.GetContextObject();
var buildMode = buildParameters.Parameters.BuildMode;
@@ -45,7 +45,7 @@ namespace YooAsset.Editor
///
/// 加密文件
///
- private List EncryptFiles(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
+ private List EncryptFiles(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
{
var encryptionServices = buildParameters.Parameters.EncryptionServices;
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
index 7105b49..b334606 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
{
void IBuildTask.Run(BuildContext context)
{
- var buildParametersContext = context.GetContextObject();
+ var buildParametersContext = context.GetContextObject();
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode);
context.SetContextObject(buildMapContext);
BuildRunner.Log("构建内容准备完毕!");
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs
index 4460128..448b602 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskPrepare.cs
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
{
void IBuildTask.Run(BuildContext context)
{
- var buildParameters = context.GetContextObject();
+ var buildParameters = context.GetContextObject();
buildParameters.BeginWatch();
// 检测构建平台是否合法
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
index 44a6bf9..b2fc07c 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
{
void IBuildTask.Run(BuildContext context)
{
- var buildParametersContext = context.GetContextObject();
+ var buildParametersContext = context.GetContextObject();
// 模拟构建模式下跳过验证
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
@@ -32,7 +32,7 @@ namespace YooAsset.Editor
///
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
{
- var buildParameters = context.GetContextObject();
+ var buildParameters = context.GetContextObject();
var buildMapContext = context.GetContextObject();
string[] buildedBundles = unityManifest.GetAllAssetBundles();