From 521e3e2587f9064b9b05f9a080a447c59b3693e7 Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 21 Feb 2023 14:52:16 +0800 Subject: [PATCH] update asset bundle builder --- .../AssetBundleBuilder/AssetBundleBuilder.cs | 2 + .../BuildTasks/TaskBuilding.cs | 26 ----------- .../BuildTasks/TaskBuilding_SBP.cs | 26 ----------- .../BuildTasks/TaskCopyRawFile.cs | 44 +++++++++++++++++++ .../BuildTasks/TaskCopyRawFile.cs.meta | 11 +++++ 5 files changed, 57 insertions(+), 52 deletions(-) create mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs create mode 100644 Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs index ca3b3e0..960c97b 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs @@ -54,6 +54,7 @@ namespace YooAsset.Editor new TaskPrepare(), //前期准备工作 new TaskGetBuildMap(), //获取构建列表 new TaskBuilding(), //开始执行构建 + new TaskCopyRawFile(), //拷贝原生文件 new TaskVerifyBuildResult(), //验证构建结果 new TaskEncryption(), //加密资源文件 new TaskUpdateBuildInfo(), //更新构建信息 @@ -70,6 +71,7 @@ namespace YooAsset.Editor new TaskPrepare(), //前期准备工作 new TaskGetBuildMap(), //获取构建列表 new TaskBuilding_SBP(), //开始执行构建 + new TaskCopyRawFile(), //拷贝原生文件 new TaskVerifyBuildResult_SBP(), //验证构建结果 new TaskEncryption(), //加密资源文件 new TaskUpdateBuildInfo(), //更新构建信息 diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs index 87ed746..89177eb 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding.cs @@ -45,32 +45,6 @@ namespace YooAsset.Editor BuildResultContext buildResultContext = new BuildResultContext(); buildResultContext.UnityManifest = buildResults; context.SetContextObject(buildResultContext); - - // 拷贝原生文件 - if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild) - { - CopyRawBundle(buildMapContext, buildParametersContext); - } - } - - /// - /// 拷贝原生文件 - /// - private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext) - { - string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); - foreach (var bundleInfo in buildMapContext.BundleInfos) - { - if (bundleInfo.IsRawFile) - { - string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; - foreach (var buildAsset in bundleInfo.BuildinAssets) - { - if (buildAsset.IsRawAsset) - EditorTools.CopyFile(buildAsset.AssetPath, dest, true); - } - } - } } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs index 6c7ae23..5f4323a 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs @@ -44,32 +44,6 @@ namespace YooAsset.Editor BuildResultContext buildResultContext = new BuildResultContext(); buildResultContext.Results = buildResults; context.SetContextObject(buildResultContext); - - // 拷贝原生文件 - if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild) - { - CopyRawBundle(buildMapContext, buildParametersContext); - } - } - - /// - /// 拷贝原生文件 - /// - private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext) - { - string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); - foreach (var bundleInfo in buildMapContext.BundleInfos) - { - if (bundleInfo.IsRawFile) - { - string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; - foreach (var buildAsset in bundleInfo.BuildinAssets) - { - if (buildAsset.IsRawAsset) - EditorTools.CopyFile(buildAsset.AssetPath, dest, true); - } - } - } } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs new file mode 100644 index 0000000..98dc140 --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs @@ -0,0 +1,44 @@ +using System; +using System.Linq; +using System.Collections; +using System.Collections.Generic; + +namespace YooAsset.Editor +{ + [TaskAttribute("拷贝原生文件")] + public class TaskCopyRawFile : IBuildTask + { + void IBuildTask.Run(BuildContext context) + { + var buildParametersContext = context.GetContextObject(); + var buildParameters = context.GetContextObject(); + var buildMapContext = context.GetContextObject(); + + var buildMode = buildParameters.Parameters.BuildMode; + if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild) + { + CopyRawBundle(buildMapContext, buildParametersContext); + } + } + + /// + /// 拷贝原生文件 + /// + private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext) + { + string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); + foreach (var bundleInfo in buildMapContext.BundleInfos) + { + if (bundleInfo.IsRawFile) + { + string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; + foreach (var buildAsset in bundleInfo.BuildinAssets) + { + if (buildAsset.IsRawAsset) + EditorTools.CopyFile(buildAsset.AssetPath, dest, true); + } + } + } + } + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs.meta new file mode 100644 index 0000000..a803fb3 --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyRawFile.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3625d4b8b5b79324ebf7ec19a87677e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: