Update AssetBundleCollector window

修复StaticAssetCollector无法预览Main Assets列表的问题。
pull/17/head
hevinci 2022-06-23 14:07:12 +08:00
parent 9b80300f19
commit 60f6483a86
4 changed files with 16 additions and 18 deletions

View File

@ -87,10 +87,10 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取打包收集的资源文件 /// 获取打包收集的资源文件
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(AssetBundleCollectorGroup group) public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, AssetBundleCollectorGroup group)
{ {
// 注意:模拟构建模式下只收集主资源 // 注意:模拟构建模式下只收集主资源
if (AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
{ {
if (CollectorType != ECollectorType.MainAssetCollector) if (CollectorType != ECollectorType.MainAssetCollector)
return new List<CollectAssetInfo>(); return new List<CollectAssetInfo>();
@ -117,7 +117,7 @@ namespace YooAsset.Editor
{ {
if (result.ContainsKey(assetPath) == false) if (result.ContainsKey(assetPath) == false)
{ {
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset); var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
result.Add(assetPath, collectAssetInfo); result.Add(assetPath, collectAssetInfo);
} }
else else
@ -132,7 +132,7 @@ namespace YooAsset.Editor
string assetPath = CollectPath; string assetPath = CollectPath;
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath)) if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
{ {
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset); var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
result.Add(assetPath, collectAssetInfo); result.Add(assetPath, collectAssetInfo);
} }
else else
@ -162,13 +162,19 @@ namespace YooAsset.Editor
return result.Values.ToList(); 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 address = GetAddress(group, assetPath);
string bundleName = GetBundleName(group, assetPath); string bundleName = GetBundleName(group, assetPath);
List<string> assetTags = GetAssetTags(group); List<string> assetTags = GetAssetTags(group);
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset); CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
// 注意:模拟构建模式下不需要收集依赖资源
if (buildMode == EBuildMode.SimulateBuild)
collectAssetInfo.DependAssets = new List<string>();
else
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
return collectAssetInfo; return collectAssetInfo;
} }
private bool IsValidateAsset(string assetPath) private bool IsValidateAsset(string assetPath)
@ -242,10 +248,6 @@ namespace YooAsset.Editor
} }
private List<string> GetAllDependencies(string mainAssetPath) private List<string> GetAllDependencies(string mainAssetPath)
{ {
// 注意:模拟构建模式下不需要收集依赖资源
if(AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild)
return new List<string>();
List<string> result = new List<string>(); List<string> result = new List<string>();
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true); string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
foreach (string assetPath in depends) foreach (string assetPath in depends)

View File

@ -45,14 +45,14 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取打包收集的资源文件 /// 获取打包收集的资源文件
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets() public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode)
{ {
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000); Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
// 收集打包资源 // 收集打包资源
foreach (var collector in Collectors) foreach (var collector in Collectors)
{ {
var temper = collector.GetAllCollectAssets(this); var temper = collector.GetAllCollectAssets(buildMode, this);
foreach (var assetInfo in temper) foreach (var assetInfo in temper)
{ {
if (result.ContainsKey(assetInfo.AssetPath) == false) if (result.ContainsKey(assetInfo.AssetPath) == false)

View File

@ -8,8 +8,6 @@ namespace YooAsset.Editor
{ {
public class AssetBundleCollectorSetting : ScriptableObject public class AssetBundleCollectorSetting : ScriptableObject
{ {
public static EBuildMode BuildMode;
/// <summary> /// <summary>
/// 是否启用可寻址资源定位 /// 是否启用可寻址资源定位
/// </summary> /// </summary>
@ -47,14 +45,12 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode) public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode)
{ {
BuildMode = buildMode;
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000); Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
// 收集打包资源 // 收集打包资源
foreach (var group in Groups) foreach (var group in Groups)
{ {
var temper = group.GetAllCollectAssets(); var temper = group.GetAllCollectAssets(buildMode);
foreach (var assetInfo in temper) foreach (var assetInfo in temper)
{ {
if (result.ContainsKey(assetInfo.AssetPath) == false) if (result.ContainsKey(assetInfo.AssetPath) == false)

View File

@ -524,7 +524,7 @@ namespace YooAsset.Editor
try try
{ {
collectAssetInfos = collector.GetAllCollectAssets(group); collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, group);
} }
catch (System.Exception e) catch (System.Exception e)
{ {