diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
index b106394..53abb7f 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs
@@ -173,14 +173,11 @@ namespace YooAsset.Editor
if (IsRawAsset)
throw new Exception("Should never get here !");
- if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
+ if (IsShaderAsset)
{
- if (IsShaderAsset)
- {
- string shareBundleName = $"{AssetBundleCollectorSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
- _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
- return;
- }
+ string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
+ _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
+ return;
}
if (_referenceBundleNames.Count > 1)
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
index da04cb1..67fbf99 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportSummary.cs
@@ -63,16 +63,6 @@ namespace YooAsset.Editor
///
public bool CopyBuildinTagFiles;
- ///
- /// 自动收集着色器
- ///
- public bool AutoCollectShaders;
-
- ///
- /// 自动收集的着色器资源包名称
- ///
- public string ShadersBundleName;
-
///
/// 加密服务类名称
///
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/SBPBuildTasks.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/SBPBuildTasks.cs
new file mode 100644
index 0000000..ef864ec
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/SBPBuildTasks.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Linq;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEditor.Build.Pipeline;
+using UnityEditor.Build.Pipeline.Interfaces;
+
+namespace UnityEditor.Build.Pipeline.Tasks
+{
+ public static class SBPBuildTasks
+ {
+ public static IList Create(string builtInShaderBundleName)
+ {
+ var buildTasks = new List();
+
+ // Setup
+ buildTasks.Add(new SwitchToBuildPlatform());
+ buildTasks.Add(new RebuildSpriteAtlasCache());
+
+ // Player Scripts
+ buildTasks.Add(new BuildPlayerScripts());
+ buildTasks.Add(new PostScriptsCallback());
+
+ // Dependency
+ buildTasks.Add(new CalculateSceneDependencyData());
+#if UNITY_2019_3_OR_NEWER
+ buildTasks.Add(new CalculateCustomDependencyData());
+#endif
+ buildTasks.Add(new CalculateAssetDependencyData());
+ buildTasks.Add(new StripUnusedSpriteSources());
+ buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
+ buildTasks.Add(new PostDependencyCallback());
+
+ // Packing
+ buildTasks.Add(new GenerateBundlePacking());
+ buildTasks.Add(new UpdateBundleObjectLayout());
+ buildTasks.Add(new GenerateBundleCommands());
+ buildTasks.Add(new GenerateSubAssetPathMaps());
+ buildTasks.Add(new GenerateBundleMaps());
+ buildTasks.Add(new PostPackingCallback());
+
+ // Writing
+ buildTasks.Add(new WriteSerializedFiles());
+ buildTasks.Add(new ArchiveAndCompressBundles());
+ buildTasks.Add(new AppendBundleHash());
+ buildTasks.Add(new GenerateLinkXml());
+ buildTasks.Add(new PostWritingCallback());
+
+ return buildTasks;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/SBPBuildTasks.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/SBPBuildTasks.cs.meta
new file mode 100644
index 0000000..2767c0b
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/SBPBuildTasks.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f38422f6a64300243af6b4fbf84644ba
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
index 8c141df..d274a0d 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskBuilding_SBP.cs
@@ -2,11 +2,10 @@
using System.Linq;
using System.Collections;
using System.Collections.Generic;
-using UnityEditor;
-using UnityEngine;
using UnityEditor.Build.Pipeline;
using UnityEditor.Build.Pipeline.Interfaces;
+using UnityEditor.Build.Pipeline.Tasks;
namespace YooAsset.Editor
{
@@ -34,7 +33,8 @@ namespace YooAsset.Editor
// 开始构建
IBundleBuildResults buildResults;
var buildParameters = buildParametersContext.GetSBPBuildParameters();
- var taskList = DefaultBuildTasks.Create(DefaultBuildTasks.Preset.AssetBundleBuiltInShaderExtraction);
+ var shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName();
+ var taskList = SBPBuildTasks.Create(shadersBunldeName);
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
if (exitCode < 0)
{
@@ -46,13 +46,6 @@ namespace YooAsset.Editor
buildResultContext.Results = buildResults;
context.SetContextObject(buildResultContext);
- // 添加Unity内置资源包信息
- if (buildResults.BundleInfos.Keys.Any(t => t == YooAssetSettings.UnityBuiltInShadersBundleName))
- {
- BuildBundleInfo builtInBundleInfo = new BuildBundleInfo(YooAssetSettings.UnityBuiltInShadersBundleName);
- buildMapContext.BundleInfos.Add(builtInBundleInfo);
- }
-
// 拷贝原生文件
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
{
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
index 194ee24..aae167e 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs
@@ -183,24 +183,31 @@ namespace YooAsset.Editor
///
private void UpdateBuiltInBundleReference(PatchManifest patchManifest, IBundleBuildResults buildResults)
{
- // 获取所有依赖内置资源包的资源包列表
- List builtInBundleReferenceList = new List();
+ // 获取所有依赖着色器资源包的资源包列表
+ string shadersBunldeName = YooAssetSettingsData.GetUnityShadersBundleFullName();
+ List shaderBundleReferenceList = new List();
foreach (var valuePair in buildResults.BundleInfos)
{
- if (valuePair.Value.Dependencies.Any(t => t == YooAssetSettings.UnityBuiltInShadersBundleName))
- builtInBundleReferenceList.Add(valuePair.Key);
+ if (valuePair.Value.Dependencies.Any(t => t == shadersBunldeName))
+ shaderBundleReferenceList.Add(valuePair.Key);
}
+ // 获取着色器资源包索引
+ Predicate predicate = new Predicate(s => s.BundleName == shadersBunldeName);
+ int shaderBundleId = patchManifest.BundleList.FindIndex(predicate);
+ if (shaderBundleId == -1)
+ throw new Exception("没有发现着色器资源包!");
+
// 检测依赖交集并更新依赖ID
- int builtInBundleId = patchManifest.BundleList.Count - 1;
foreach (var patchAsset in patchManifest.AssetList)
{
List dependBundles = GetPatchAssetAllDependBundles(patchManifest, patchAsset);
- List conflictAssetPathList = dependBundles.Intersect(builtInBundleReferenceList).ToList();
+ List conflictAssetPathList = dependBundles.Intersect(shaderBundleReferenceList).ToList();
if (conflictAssetPathList.Count > 0)
{
List newDependIDs = new List(patchAsset.DependIDs);
- newDependIDs.Add(builtInBundleId);
+ if(newDependIDs.Contains(shaderBundleId) == false)
+ newDependIDs.Add(shaderBundleId);
patchAsset.DependIDs = newDependIDs.ToArray();
}
}
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
index 91f4af2..dc68407 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs
@@ -48,8 +48,6 @@ namespace YooAsset.Editor
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
buildReport.Summary.CopyBuildinTagFiles = buildParameters.Parameters.CopyBuildinTagFiles;
- buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
- buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
index b5102d4..2950e3e 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult.cs
@@ -14,7 +14,7 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context)
{
var buildParametersContext = context.GetContextObject();
-
+
// 模拟构建模式下跳过验证
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
return;
@@ -37,20 +37,31 @@ namespace YooAsset.Editor
string[] buildedBundles = unityManifest.GetAllAssetBundles();
// 1. 过滤掉原生Bundle
- string[] expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
+ string[] mapBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
// 2. 验证Bundle
- List intersectBundleList = buildedBundles.Except(expectBundles).ToList();
- if (intersectBundleList.Count > 0)
+ List exceptBundleList1 = buildedBundles.Except(mapBundles).ToList();
+ if (exceptBundleList1.Count > 0)
{
- foreach (var intersectBundle in intersectBundleList)
+ foreach (var exceptBundle in exceptBundleList1)
{
- Debug.LogWarning($"差异资源包: {intersectBundle}");
+ Debug.LogWarning($"差异资源包: {exceptBundle}");
}
throw new System.Exception("存在差异资源包!请查看警告信息!");
}
- // 3. 验证Asset
+ // 3. 验证Bundle
+ List exceptBundleList2 = mapBundles.Except(buildedBundles).ToList();
+ if (exceptBundleList2.Count > 0)
+ {
+ foreach (var exceptBundle in exceptBundleList2)
+ {
+ Debug.LogWarning($"差异资源包: {exceptBundle}");
+ }
+ throw new System.Exception("存在差异资源包!请查看警告信息!");
+ }
+
+ // 4. 验证Asset
bool isPass = true;
var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
@@ -59,15 +70,20 @@ namespace YooAsset.Editor
foreach (var buildedBundle in buildedBundles)
{
string filePath = $"{buildParameters.PipelineOutputDirectory}/{buildedBundle}";
- string[] allBuildinAssetPaths = GetAssetBundleAllAssets(filePath);
- string[] expectBuildinAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
- if (expectBuildinAssetPaths.Length != allBuildinAssetPaths.Length)
+ string[] buildedAssetPaths = GetAssetBundleAllAssets(filePath);
+ string[] mapAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
+ if (mapAssetPaths.Length != buildedAssetPaths.Length)
{
Debug.LogWarning($"构建的Bundle文件内的资源对象数量和预期不匹配 : {buildedBundle}");
- var intersectAssetList = expectBuildinAssetPaths.Except(allBuildinAssetPaths).ToList();
- foreach (var intersectAssset in intersectAssetList)
+ var exceptAssetList1 = mapAssetPaths.Except(buildedAssetPaths).ToList();
+ foreach (var excpetAsset in exceptAssetList1)
{
- Debug.LogWarning($"构建失败的资源对象路径为 : {intersectAssset}");
+ Debug.LogWarning($"构建失败的资源对象路径为 : {excpetAsset}");
+ }
+ var exceptAssetList2 = buildedAssetPaths.Except(mapAssetPaths).ToList();
+ foreach (var excpetAsset in exceptAssetList2)
+ {
+ Debug.LogWarning($"构建失败的资源对象路径为 : {excpetAsset}");
}
isPass = false;
continue;
@@ -75,6 +91,7 @@ namespace YooAsset.Editor
EditorTools.DisplayProgressBar("验证构建结果", ++progressValue, buildedBundles.Length);
}
EditorTools.ClearProgressBar();
+
if (isPass == false)
{
throw new Exception("构建结果验证没有通过,请参考警告日志!");
diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
index 0415b74..a1b2078 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskVerifyBuildResult_SBP.cs
@@ -35,21 +35,29 @@ namespace YooAsset.Editor
{
var buildParameters = context.GetContextObject();
var buildMapContext = context.GetContextObject();
-
- // 1. 移除特定Bundle
List buildedBundles = buildResults.BundleInfos.Keys.ToList();
- buildedBundles.Remove(YooAssetSettings.UnityBuiltInShadersBundleName);
- // 2. 过滤掉原生Bundle
+ // 1. 过滤掉原生Bundle
List expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
- // 3. 验证Bundle
- List intersectBundleList = buildedBundles.Except(expectBundles).ToList();
- if (intersectBundleList.Count > 0)
+ // 2. 验证Bundle
+ List exceptBundleList1 = buildedBundles.Except(expectBundles).ToList();
+ if (exceptBundleList1.Count > 0)
{
- foreach (var intersectBundle in intersectBundleList)
+ foreach (var exceptBundle in exceptBundleList1)
{
- Debug.LogWarning($"差异资源包: {intersectBundle}");
+ Debug.LogWarning($"差异资源包: {exceptBundle}");
+ }
+ throw new System.Exception("存在差异资源包!请查看警告信息!");
+ }
+
+ // 3. 验证Bundle
+ List exceptBundleList2 = expectBundles.Except(buildedBundles).ToList();
+ if (exceptBundleList2.Count > 0)
+ {
+ foreach (var exceptBundle in exceptBundleList2)
+ {
+ Debug.LogWarning($"差异资源包: {exceptBundle}");
}
throw new System.Exception("存在差异资源包!请查看警告信息!");
}