diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs index e027e8d7..b2b1455c 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs @@ -13,6 +13,11 @@ namespace YooAsset.Editor /// private readonly Dictionary _bundleInfoDic = new Dictionary(10000); + /// + /// 图集资源集合 + /// + public readonly List SpriteAtlasAssetList = new List(10000); + /// /// 未被依赖的资源列表 /// @@ -60,6 +65,12 @@ namespace YooAsset.Editor newBundleInfo.PackAsset(assetInfo); _bundleInfoDic.Add(bundleName, newBundleInfo); } + + // 统计所有的精灵图集 + if (assetInfo.AssetInfo.IsSpriteAtlas()) + { + SpriteAtlasAssetList.Add(assetInfo); + } } /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs index 305d8ee3..263f126b 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateManifest.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Collections; using System.Collections.Generic; +using UnityEditor; namespace YooAsset.Editor { @@ -301,15 +302,28 @@ namespace YooAsset.Editor #region YOOASSET_LEGACY_DEPENDENCY private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest) { + // 注意:初始化资源清单建立引用关系 + ManifestTools.InitManifest(manifest); + // 注意:如果是可编程构建管线,需要补充内置资源包 // 注意:该步骤依赖前面的操作! var buildResultContext = context.TryGetContextObject(); if (buildResultContext != null) { - // 注意:初始化资源清单建立引用关系 - ManifestTools.InitManifest(manifest); ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName); ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName); + + // 注意:检测是否开启图集模式 + // 说明:需要记录主资源对象对图集的依赖关系! + if (EditorSettings.spritePackerMode != SpritePackerMode.Disabled) + { + var buildMapContext = context.GetContextObject(); + foreach (var spriteAtlasAsset in buildMapContext.SpriteAtlasAssetList) + { + string spriteAtlasBundleName = spriteAtlasAsset.BundleName; + ProcessBuiltinBundleReference(context, manifest, spriteAtlasBundleName); + } + } } } private void ProcessBuiltinBundleReference(BuildContext context, PackageManifest manifest, string builtinBundleName) diff --git a/Assets/YooAsset/Editor/Common/AssetInfo.cs b/Assets/YooAsset/Editor/Common/AssetInfo.cs index bef65871..615fef97 100644 --- a/Assets/YooAsset/Editor/Common/AssetInfo.cs +++ b/Assets/YooAsset/Editor/Common/AssetInfo.cs @@ -62,6 +62,17 @@ namespace YooAsset.Editor return false; } + /// + /// 是否为图集资源 + /// + public bool IsSpriteAtlas() + { + if (AssetType == typeof(UnityEngine.U2D.SpriteAtlas)) + return true; + else + return false; + } + public int CompareTo(AssetInfo other) { return this.AssetPath.CompareTo(other.AssetPath);