mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-27 03:00:17 +00:00
feat : 在SBP构建管线里,自动建立主资源对象对图集的依赖关系
This commit is contained in:
@@ -13,6 +13,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 图集资源集合
|
||||||
|
/// </summary>
|
||||||
|
public readonly List<BuildAssetInfo> SpriteAtlasAssetList = new List<BuildAssetInfo>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 未被依赖的资源列表
|
/// 未被依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -60,6 +65,12 @@ namespace YooAsset.Editor
|
|||||||
newBundleInfo.PackAsset(assetInfo);
|
newBundleInfo.PackAsset(assetInfo);
|
||||||
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 统计所有的精灵图集
|
||||||
|
if (assetInfo.AssetInfo.IsSpriteAtlas())
|
||||||
|
{
|
||||||
|
SpriteAtlasAssetList.Add(assetInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -301,15 +302,28 @@ namespace YooAsset.Editor
|
|||||||
#region YOOASSET_LEGACY_DEPENDENCY
|
#region YOOASSET_LEGACY_DEPENDENCY
|
||||||
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
|
// 注意:初始化资源清单建立引用关系
|
||||||
|
ManifestTools.InitManifest(manifest);
|
||||||
|
|
||||||
// 注意:如果是可编程构建管线,需要补充内置资源包
|
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||||
// 注意:该步骤依赖前面的操作!
|
// 注意:该步骤依赖前面的操作!
|
||||||
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
if (buildResultContext != null)
|
if (buildResultContext != null)
|
||||||
{
|
{
|
||||||
// 注意:初始化资源清单建立引用关系
|
|
||||||
ManifestTools.InitManifest(manifest);
|
|
||||||
ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName);
|
ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName);
|
||||||
ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName);
|
ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName);
|
||||||
|
|
||||||
|
// 注意:检测是否开启图集模式
|
||||||
|
// 说明:需要记录主资源对象对图集的依赖关系!
|
||||||
|
if (EditorSettings.spritePackerMode != SpritePackerMode.Disabled)
|
||||||
|
{
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
foreach (var spriteAtlasAsset in buildMapContext.SpriteAtlasAssetList)
|
||||||
|
{
|
||||||
|
string spriteAtlasBundleName = spriteAtlasAsset.BundleName;
|
||||||
|
ProcessBuiltinBundleReference(context, manifest, spriteAtlasBundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ProcessBuiltinBundleReference(BuildContext context, PackageManifest manifest, string builtinBundleName)
|
private void ProcessBuiltinBundleReference(BuildContext context, PackageManifest manifest, string builtinBundleName)
|
||||||
|
|||||||
@@ -62,6 +62,17 @@ namespace YooAsset.Editor
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为图集资源
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSpriteAtlas()
|
||||||
|
{
|
||||||
|
if (AssetType == typeof(UnityEngine.U2D.SpriteAtlas))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public int CompareTo(AssetInfo other)
|
public int CompareTo(AssetInfo other)
|
||||||
{
|
{
|
||||||
return this.AssetPath.CompareTo(other.AssetPath);
|
return this.AssetPath.CompareTo(other.AssetPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user