This commit is contained in:
何冠峰
2025-09-13 18:18:31 +08:00
parent be71d38cd8
commit 0934c813d1
3 changed files with 70 additions and 4 deletions

View File

@@ -139,6 +139,20 @@ namespace YooAsset.Editor
/// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
{
bool ignoreStaticCollector = command.IsFlagSet(ECollectFlags.IgnoreStaticCollector);
if (ignoreStaticCollector)
{
if (CollectorType == ECollectorType.StaticAssetCollector)
return new List<CollectAssetInfo>();
}
bool ignoreDependCollector = command.IsFlagSet(ECollectFlags.IgnoreDependCollector);
if (ignoreDependCollector)
{
if (CollectorType == ECollectorType.DependAssetCollector)
return new List<CollectAssetInfo>();
}
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
// 收集打包资源路径
@@ -262,8 +276,8 @@ namespace YooAsset.Editor
}
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
{
// 注意:模拟构建模式下不需要收集依赖资源
if (command.SimulateBuild)
bool ignoreGetDependencies = command.IsFlagSet(ECollectFlags.IgnoreGetDependencies);
if (ignoreGetDependencies)
return new List<AssetInfo>();
string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true);

View File

@@ -1028,7 +1028,7 @@ namespace YooAsset.Editor
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
string packageName = _packageNameTxt.value;
var command = new CollectCommand(packageName, ignoreRule);
command.SimulateBuild = true;
command.SetFlag(ECollectFlags.IgnoreGetDependencies, true);
command.UniqueBundleName = _uniqueBundleNameToogle.value;
command.EnableAddressable = _enableAddressableToogle.value;
command.SupportExtensionless = _supportExtensionlessToogle.value;

View File

@@ -1,6 +1,26 @@

namespace YooAsset.Editor
{
public enum ECollectFlags
{
None = 0,
/// <summary>
/// 不收集依赖资源
/// </summary>
IgnoreGetDependencies = 1 << 0,
/// <summary>
/// 忽略静态收集器
/// </summary>
IgnoreStaticCollector = 1 << 1,
/// <summary>
/// 忽略依赖收集器
/// </summary>
IgnoreDependCollector = 1 << 2,
}
public class CollectCommand
{
/// <summary>
@@ -17,7 +37,20 @@ namespace YooAsset.Editor
/// <summary>
/// 模拟构建模式
/// </summary>
public bool SimulateBuild { set; get; }
public bool SimulateBuild
{
set
{
SetFlag(ECollectFlags.IgnoreGetDependencies, value);
SetFlag(ECollectFlags.IgnoreStaticCollector, value);
SetFlag(ECollectFlags.IgnoreDependCollector, value);
}
}
/// <summary>
/// 窗口收集模式
/// </summary>
public int CollectFlags { set; get; } = 0;
/// <summary>
/// 资源包名唯一化
@@ -70,5 +103,24 @@ namespace YooAsset.Editor
PackageName = packageName;
IgnoreRule = ignoreRule;
}
/// <summary>
/// 设置标记位
/// </summary>
public void SetFlag(ECollectFlags flag, bool isOn)
{
if (isOn)
CollectFlags |= (int)flag; // 开启指定标志位
else
CollectFlags &= ~(int)flag; // 关闭指定标志位
}
/// <summary>
/// 查询标记位
/// </summary>
public bool IsFlagSet(ECollectFlags flag)
{
return (CollectFlags & (int)flag) != 0;
}
}
}