diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
index f54a8e1..e09aee2 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollector.cs
@@ -87,10 +87,10 @@ namespace YooAsset.Editor
///
/// 获取打包收集的资源文件
///
- public List GetAllCollectAssets(AssetBundleCollectorGroup group)
+ public List GetAllCollectAssets(EBuildMode buildMode, AssetBundleCollectorGroup group)
{
// 注意:模拟构建模式下只收集主资源
- if (AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild)
+ if (buildMode == EBuildMode.SimulateBuild)
{
if (CollectorType != ECollectorType.MainAssetCollector)
return new List();
@@ -117,7 +117,7 @@ namespace YooAsset.Editor
{
if (result.ContainsKey(assetPath) == false)
{
- var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset);
+ var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
result.Add(assetPath, collectAssetInfo);
}
else
@@ -132,7 +132,7 @@ namespace YooAsset.Editor
string assetPath = CollectPath;
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
{
- var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset);
+ var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
result.Add(assetPath, collectAssetInfo);
}
else
@@ -162,13 +162,19 @@ namespace YooAsset.Editor
return result.Values.ToList();
}
- private CollectAssetInfo CreateCollectAssetInfo(AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
+ private CollectAssetInfo CreateCollectAssetInfo(EBuildMode buildMode, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
{
string address = GetAddress(group, assetPath);
string bundleName = GetBundleName(group, assetPath);
List assetTags = GetAssetTags(group);
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
- collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
+
+ // 注意:模拟构建模式下不需要收集依赖资源
+ if (buildMode == EBuildMode.SimulateBuild)
+ collectAssetInfo.DependAssets = new List();
+ else
+ collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
+
return collectAssetInfo;
}
private bool IsValidateAsset(string assetPath)
@@ -242,10 +248,6 @@ namespace YooAsset.Editor
}
private List GetAllDependencies(string mainAssetPath)
{
- // 注意:模拟构建模式下不需要收集依赖资源
- if(AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild)
- return new List();
-
List result = new List();
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
foreach (string assetPath in depends)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
index 2fe9bb9..324ba5c 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorGroup.cs
@@ -45,14 +45,14 @@ namespace YooAsset.Editor
///
/// 获取打包收集的资源文件
///
- public List GetAllCollectAssets()
+ public List GetAllCollectAssets(EBuildMode buildMode)
{
Dictionary result = new Dictionary(10000);
// 收集打包资源
foreach (var collector in Collectors)
{
- var temper = collector.GetAllCollectAssets(this);
+ var temper = collector.GetAllCollectAssets(buildMode, this);
foreach (var assetInfo in temper)
{
if (result.ContainsKey(assetInfo.AssetPath) == false)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
index 59570e7..d23c992 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorSetting.cs
@@ -8,8 +8,6 @@ namespace YooAsset.Editor
{
public class AssetBundleCollectorSetting : ScriptableObject
{
- public static EBuildMode BuildMode;
-
///
/// 是否启用可寻址资源定位
///
@@ -47,14 +45,12 @@ namespace YooAsset.Editor
///
public List GetAllCollectAssets(EBuildMode buildMode)
{
- BuildMode = buildMode;
-
Dictionary result = new Dictionary(10000);
// 收集打包资源
foreach (var group in Groups)
{
- var temper = group.GetAllCollectAssets();
+ var temper = group.GetAllCollectAssets(buildMode);
foreach (var assetInfo in temper)
{
if (result.ContainsKey(assetInfo.AssetPath) == false)
diff --git a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
index a184a82..1dfc72f 100644
--- a/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
+++ b/Assets/YooAsset/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs
@@ -524,7 +524,7 @@ namespace YooAsset.Editor
try
{
- collectAssetInfos = collector.GetAllCollectAssets(group);
+ collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, group);
}
catch (System.Exception e)
{