Update AssetBundleBuilder

pull/4/head
hevinci 2022-03-16 17:35:21 +08:00
parent 299f770692
commit a91f1bd020
8 changed files with 100 additions and 153 deletions

View File

@ -13,17 +13,12 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 资源路径 /// 资源路径
/// </summary> /// </summary>
public string AssetPath { private set; get; } public string AssetPath;
/// <summary> /// <summary>
/// 资源包标签 /// 资源包完整名称
/// </summary> /// </summary>
public string BundleLabel { private set; get; } public string BundleName;
/// <summary>
/// 资源包文件格式
/// </summary>
public string BundleVariant { private set; get; }
/// <summary> /// <summary>
/// 是否为原生资源 /// 是否为原生资源
@ -46,10 +41,10 @@ namespace YooAsset.Editor
public int DependCount = 0; public int DependCount = 0;
/// <summary> /// <summary>
/// 依赖的所有资源信息 /// 依赖的所有资源
/// 注意:包括零依赖资源(零依赖资源的资源包名无效) /// 注意:包括零依赖资源和冗余资源(资源包名无效)
/// </summary> /// </summary>
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; } = null; public List<BuildAssetInfo> AllDependAssetInfos;
public BuildAssetInfo(string assetPath) public BuildAssetInfo(string assetPath)
@ -73,11 +68,10 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public void SetBundleLabelAndVariant(string bundleLabel, string bundleVariant) public void SetBundleLabelAndVariant(string bundleLabel, string bundleVariant)
{ {
if (string.IsNullOrEmpty(BundleLabel) == false || string.IsNullOrEmpty(BundleVariant) == false) if (string.IsNullOrEmpty(BundleName) == false)
throw new System.Exception("Should never get here !"); throw new System.Exception("Should never get here !");
BundleLabel = bundleLabel; BundleName = AssetBundleBuilderHelper.MakeBundleName(bundleLabel, bundleVariant);
BundleVariant = bundleVariant;
} }
/// <summary> /// <summary>
@ -95,25 +89,14 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 获取资源包的完整名称 /// 资源包名是否有效
/// </summary> /// </summary>
public string GetBundleName() public bool BundleNameIsValid()
{ {
if (string.IsNullOrEmpty(BundleLabel) || string.IsNullOrEmpty(BundleVariant)) if (string.IsNullOrEmpty(BundleName))
throw new System.ArgumentNullException();
return AssetBundleBuilderHelper.MakeBundleName(BundleLabel, BundleVariant);
}
/// <summary>
/// 检测资源包名是否有效
/// </summary>
public bool CheckBundleNameValid()
{
if (string.IsNullOrEmpty(BundleLabel) == false && string.IsNullOrEmpty(BundleVariant) == false)
return true;
else
return false; return false;
else
return true;
} }
} }
} }

View File

@ -15,22 +15,12 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 资源包完整名称 /// 资源包完整名称
/// </summary> /// </summary>
public string BundleName { private set; get; } public string BundleName;
/// <summary>
/// 资源包标签名
/// </summary>
public string BundleLabel { private set; get; }
/// <summary>
/// 资源包文件格式
/// </summary>
public string BundleVariant { private set; get; }
/// <summary> /// <summary>
/// 包含的资源列表 /// 包含的资源列表
/// </summary> /// </summary>
public readonly List<BuildAssetInfo> Assets = new List<BuildAssetInfo>(); public List<BuildAssetInfo> Assets = new List<BuildAssetInfo>();
/// <summary> /// <summary>
/// 是否为原生文件 /// 是否为原生文件
@ -49,11 +39,9 @@ namespace YooAsset.Editor
} }
public BuildBundleInfo(string bundleLabel, string bundleVariant) public BuildBundleInfo(string bundleName)
{ {
BundleLabel = bundleLabel; BundleName = bundleName;
BundleVariant = bundleVariant;
BundleName = AssetBundleBuilderHelper.MakeBundleName(bundleLabel, bundleVariant);
} }
/// <summary> /// <summary>
@ -110,14 +98,6 @@ namespace YooAsset.Editor
return result.ToArray(); return result.ToArray();
} }
/// <summary>
/// 获取主动收集的资源路径列表
/// </summary>
public string[] GetCollectAssetPaths()
{
return Assets.Where(t => t.IsCollectAsset).Select(t => t.AssetPath).ToArray();
}
/// <summary> /// <summary>
/// 获取构建的资源路径列表 /// 获取构建的资源路径列表
/// </summary> /// </summary>

View File

@ -1,10 +1,8 @@
using System; using System;
using System.IO;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine;
namespace YooAsset namespace YooAsset.Editor
{ {
/// <summary> /// <summary>
/// 构建报告 /// 构建报告
@ -12,6 +10,40 @@ namespace YooAsset
[Serializable] [Serializable]
public class BuildReport public class BuildReport
{ {
/// <summary>
/// 资源包列表
/// </summary>
public readonly List<BuildBundleInfo> BundleInfos = new List<BuildBundleInfo>(1000);
/// <summary>
/// 冗余的资源列表
/// </summary>
public readonly List<string> RedundancyList = new List<string>(1000);
/// <summary>
/// 检测是否包含BundleName
/// </summary>
public bool IsContainsBundle(string bundleFullName)
{
return TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo);
}
/// <summary>
/// 尝试获取资源包类,如果没有返回空
/// </summary>
public bool TryGetBundleInfo(string bundleFullName, out BuildBundleInfo result)
{
foreach (var bundleInfo in BundleInfos)
{
if (bundleInfo.BundleName == bundleFullName)
{
result = bundleInfo;
return true;
}
}
result = null;
return false;
}
} }
} }

View File

@ -31,7 +31,7 @@ namespace YooAsset.Editor
context.SetContextObject(unityManifestContext); context.SetContextObject(unityManifestContext);
// 拷贝原生文件 // 拷贝原生文件
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
{ {
if (bundleInfo.IsRawFile) if (bundleInfo.IsRawFile)
{ {
@ -62,7 +62,7 @@ namespace YooAsset.Editor
// 1. 过滤掉原生Bundle // 1. 过滤掉原生Bundle
List<BuildBundleInfo> expectBundles = new List<BuildBundleInfo>(buildedBundles.Length); List<BuildBundleInfo> expectBundles = new List<BuildBundleInfo>(buildedBundles.Length);
foreach(var bundleInfo in buildMapContext.BundleInfos) foreach(var bundleInfo in buildMapContext.Report.BundleInfos)
{ {
if (bundleInfo.IsRawFile == false) if (bundleInfo.IsRawFile == false)
expectBundles.Add(bundleInfo); expectBundles.Add(bundleInfo);
@ -77,7 +77,7 @@ namespace YooAsset.Editor
// 3. 正向验证Bundle // 3. 正向验证Bundle
foreach (var bundleName in buildedBundles) foreach (var bundleName in buildedBundles)
{ {
if (buildMapContext.IsContainsBundle(bundleName) == false) if (buildMapContext.Report.IsContainsBundle(bundleName) == false)
{ {
throw new Exception($"Should never get here !"); throw new Exception($"Should never get here !");
} }

View File

@ -29,7 +29,7 @@ namespace YooAsset.Editor
patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion; patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion;
patchManifest.BuildinTags = buildParameters.Parameters.BuildinTags; patchManifest.BuildinTags = buildParameters.Parameters.BuildinTags;
patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext); patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext);
patchManifest.AssetList = GetAllPatchAsset(buildMapContext, patchManifest.BundleList); patchManifest.AssetList = GetAllPatchAsset(buildMapContext, patchManifest);
// 创建补丁清单文件 // 创建补丁清单文件
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.PatchManifestFileName}"; string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.PatchManifestFileName}";
@ -61,7 +61,7 @@ namespace YooAsset.Editor
oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory); oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
} }
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
{ {
var bundleName = bundleInfo.BundleName; var bundleName = bundleInfo.BundleName;
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}"; string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
@ -111,41 +111,41 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取资源列表 /// 获取资源列表
/// </summary> /// </summary>
private List<PatchAsset> GetAllPatchAsset(TaskGetBuildMap.BuildMapContext buildMapContext, List<PatchBundle> bundleList) private List<PatchAsset> GetAllPatchAsset(TaskGetBuildMap.BuildMapContext buildMapContext, PatchManifest patchManifest)
{ {
List<PatchAsset> result = new List<PatchAsset>(1000); List<PatchAsset> result = new List<PatchAsset>(1000);
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
{ {
var assetInfos = bundleInfo.GetCollectAssetInfos(); var assetInfos = bundleInfo.GetCollectAssetInfos();
foreach (var assetInfo in assetInfos) foreach (var assetInfo in assetInfos)
{ {
PatchAsset patchAsset = new PatchAsset(); PatchAsset patchAsset = new PatchAsset();
patchAsset.AssetPath = assetInfo.AssetPath; patchAsset.AssetPath = assetInfo.AssetPath;
patchAsset.BundleID = GetAssetBundleID(assetInfo.GetBundleName(), bundleList); patchAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, patchManifest);
patchAsset.DependIDs = GetAssetBundleDependIDs(assetInfo, bundleList); patchAsset.DependIDs = GetAssetBundleDependIDs(assetInfo, patchManifest);
result.Add(patchAsset); result.Add(patchAsset);
} }
} }
return result; return result;
} }
private int[] GetAssetBundleDependIDs(BuildAssetInfo assetInfo, List<PatchBundle> bundleList) private int[] GetAssetBundleDependIDs(BuildAssetInfo assetInfo, PatchManifest patchManifest)
{ {
List<int> result = new List<int>(); List<int> result = new List<int>();
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos) foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
{ {
if (dependAssetInfo.CheckBundleNameValid() == false) if (dependAssetInfo.BundleNameIsValid() == false)
continue; continue;
int bundleID = GetAssetBundleID(dependAssetInfo.GetBundleName(), bundleList); int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, patchManifest);
if (result.Contains(bundleID) == false) if (result.Contains(bundleID) == false)
result.Add(bundleID); result.Add(bundleID);
} }
return result.ToArray(); return result.ToArray();
} }
private int GetAssetBundleID(string bundleName, List<PatchBundle> bundleList) private int GetAssetBundleID(string bundleName, PatchManifest patchManifest)
{ {
for (int index = 0; index < bundleList.Count; index++) for (int index = 0; index < patchManifest.BundleList.Count; index++)
{ {
if (bundleList[index].BundleName == bundleName) if (patchManifest.BundleList[index].BundleName == bundleName)
return index; return index;
} }
throw new Exception($"Not found bundle name : {bundleName}"); throw new Exception($"Not found bundle name : {bundleName}");

View File

@ -77,17 +77,17 @@ namespace YooAsset.Editor
AppendData(content, ""); AppendData(content, "");
AppendData(content, $"--冗余列表--"); AppendData(content, $"--冗余列表--");
for (int i = 0; i < buildMapContext.RedundancyList.Count; i++) for (int i = 0; i < buildMapContext.Report.RedundancyList.Count; i++)
{ {
string redundancyAssetPath = buildMapContext.RedundancyList[i]; string redundancyAssetPath = buildMapContext.Report.RedundancyList[i];
AppendData(content, redundancyAssetPath); AppendData(content, redundancyAssetPath);
} }
AppendData(content, ""); AppendData(content, "");
AppendData(content, $"--构建列表--"); AppendData(content, $"--构建列表--");
for (int i = 0; i < buildMapContext.BundleInfos.Count; i++) for (int i = 0; i < buildMapContext.Report.BundleInfos.Count; i++)
{ {
string bundleName = buildMapContext.BundleInfos[i].BundleName; string bundleName = buildMapContext.Report.BundleInfos[i].BundleName;
AppendData(content, bundleName); AppendData(content, bundleName);
} }

View File

@ -64,7 +64,7 @@ namespace YooAsset.Editor
UnityEngine.Debug.Log($"开始加密资源文件"); UnityEngine.Debug.Log($"开始加密资源文件");
int progressValue = 0; int progressValue = 0;
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
{ {
var bundleName = bundleInfo.BundleName; var bundleName = bundleInfo.BundleName;
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}"; string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
@ -83,7 +83,7 @@ namespace YooAsset.Editor
} }
// 进度条 // 进度条
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.BundleInfos.Count); EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.Report.BundleInfos.Count);
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();

View File

@ -11,31 +11,22 @@ namespace YooAsset.Editor
{ {
public class BuildMapContext : IContextObject public class BuildMapContext : IContextObject
{ {
/// <summary> public BuildReport Report = new BuildReport();
/// 资源包列表
/// </summary>
public readonly List<BuildBundleInfo> BundleInfos = new List<BuildBundleInfo>(1000);
/// <summary>
/// 冗余的资源列表
/// </summary>
public readonly List<string> RedundancyList = new List<string>(1000);
/// <summary> /// <summary>
/// 添加一个打包资源 /// 添加一个打包资源
/// </summary> /// </summary>
public void PackAsset(BuildAssetInfo assetInfo) public void PackAsset(BuildAssetInfo assetInfo)
{ {
if (TryGetBundleInfo(assetInfo.GetBundleName(), out BuildBundleInfo bundleInfo)) if (Report.TryGetBundleInfo(assetInfo.BundleName, out BuildBundleInfo bundleInfo))
{ {
bundleInfo.PackAsset(assetInfo); bundleInfo.PackAsset(assetInfo);
} }
else else
{ {
BuildBundleInfo newBundleInfo = new BuildBundleInfo(assetInfo.BundleLabel, assetInfo.BundleVariant); BuildBundleInfo newBundleInfo = new BuildBundleInfo(assetInfo.BundleName);
newBundleInfo.PackAsset(assetInfo); newBundleInfo.PackAsset(assetInfo);
BundleInfos.Add(newBundleInfo); Report.BundleInfos.Add(newBundleInfo);
} }
} }
@ -44,8 +35,8 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public List<BuildAssetInfo> GetAllAssets() public List<BuildAssetInfo> GetAllAssets()
{ {
List<BuildAssetInfo> result = new List<BuildAssetInfo>(BundleInfos.Count); List<BuildAssetInfo> result = new List<BuildAssetInfo>(Report.BundleInfos.Count);
foreach (var bundleInfo in BundleInfos) foreach (var bundleInfo in Report.BundleInfos)
{ {
result.AddRange(bundleInfo.Assets); result.AddRange(bundleInfo.Assets);
} }
@ -57,31 +48,19 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string[] GetAssetTags(string bundleFullName) public string[] GetAssetTags(string bundleFullName)
{ {
if (TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo)) if (Report.TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo))
{ {
return bundleInfo.GetAssetTags(); return bundleInfo.GetAssetTags();
} }
throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleFullName}"); throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleFullName}");
} }
/// <summary>
/// 获取AssetBundle内收集的资源路径列表
/// </summary>
public string[] GetCollectAssetPaths(string bundleFullName)
{
if (TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo))
{
return bundleInfo.GetCollectAssetPaths();
}
throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleFullName}");
}
/// <summary> /// <summary>
/// 获取AssetBundle内构建的资源路径列表 /// 获取AssetBundle内构建的资源路径列表
/// </summary> /// </summary>
public string[] GetBuildinAssetPaths(string bundleFullName) public string[] GetBuildinAssetPaths(string bundleFullName)
{ {
if (TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo)) if (Report.TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo))
{ {
return bundleInfo.GetBuildinAssetPaths(); return bundleInfo.GetBuildinAssetPaths();
} }
@ -93,36 +72,14 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds() public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
{ {
List<AssetBundleBuild> builds = new List<AssetBundleBuild>(BundleInfos.Count); List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(Report.BundleInfos.Count);
foreach (var bundleInfo in BundleInfos) foreach (var bundleInfo in Report.BundleInfos)
{ {
if (bundleInfo.IsRawFile == false) if (bundleInfo.IsRawFile == false)
builds.Add(bundleInfo.CreatePipelineBuild()); builds.Add(bundleInfo.CreatePipelineBuild());
} }
return builds.ToArray(); return builds.ToArray();
} }
/// <summary>
/// 检测是否包含BundleName
/// </summary>
public bool IsContainsBundle(string bundleFullName)
{
return TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo);
}
private bool TryGetBundleInfo(string bundleFullName, out BuildBundleInfo result)
{
foreach (var bundleInfo in BundleInfos)
{
if (bundleInfo.BundleName == bundleFullName)
{
result = bundleInfo;
return true;
}
}
result = null;
return false;
}
} }
@ -142,7 +99,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private void SetupBuildMap(BuildMapContext buildMapContext, AssetBundleBuilder.BuildParametersContext buildParameters) private void SetupBuildMap(BuildMapContext buildMapContext, AssetBundleBuilder.BuildParametersContext buildParameters)
{ {
Dictionary<string, BuildAssetInfo> buildAssets = new Dictionary<string, BuildAssetInfo>(); Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>();
// 1. 获取主动收集的资源 // 1. 获取主动收集的资源
List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.GetAllCollectAssets(); List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.GetAllCollectAssets();
@ -160,23 +117,19 @@ namespace YooAsset.Editor
string assetPath = depends[i].AssetPath; string assetPath = depends[i].AssetPath;
// 如果已经存在,则增加该资源的依赖计数 // 如果已经存在,则增加该资源的依赖计数
if (buildAssets.ContainsKey(assetPath)) if (buildAssetDic.ContainsKey(assetPath))
{ buildAssetDic[assetPath].DependCount++;
buildAssets[assetPath].DependCount++;
}
else else
{ buildAssetDic.Add(assetPath, depends[i]);
buildAssets.Add(assetPath, depends[i]);
}
// 添加资源标记 // 添加资源标记
buildAssets[assetPath].AddAssetTags(collectInfo.AssetTags); buildAssetDic[assetPath].AddAssetTags(collectInfo.AssetTags);
// 注意:检测是否为主动收集资源 // 注意:检测是否为主动收集资源
if (assetPath == mainAssetPath) if (assetPath == mainAssetPath)
{ {
buildAssets[mainAssetPath].IsCollectAsset = true; buildAssetDic[mainAssetPath].IsCollectAsset = true;
buildAssets[mainAssetPath].IsRawAsset = collectInfo.IsRawAsset; buildAssetDic[mainAssetPath].IsRawAsset = collectInfo.IsRawAsset;
} }
} }
@ -187,9 +140,9 @@ namespace YooAsset.Editor
{ {
string assetPath = depends[i].AssetPath; string assetPath = depends[i].AssetPath;
if (assetPath != mainAssetPath) if (assetPath != mainAssetPath)
allDependAssetInfos.Add(buildAssets[assetPath]); allDependAssetInfos.Add(buildAssetDic[assetPath]);
} }
buildAssets[mainAssetPath].SetAllDependAssetInfos(allDependAssetInfos); buildAssetDic[mainAssetPath].SetAllDependAssetInfos(allDependAssetInfos);
EditorTools.DisplayProgressBar("依赖文件分析", ++progressValue, allCollectInfos.Count); EditorTools.DisplayProgressBar("依赖文件分析", ++progressValue, allCollectInfos.Count);
} }
@ -198,7 +151,7 @@ namespace YooAsset.Editor
// 3. 移除零依赖的资源 // 3. 移除零依赖的资源
var redundancy = CreateAssetRedundancy(); var redundancy = CreateAssetRedundancy();
List<BuildAssetInfo> undependentAssets = new List<BuildAssetInfo>(); List<BuildAssetInfo> undependentAssets = new List<BuildAssetInfo>();
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssets) foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
{ {
var buildAssetInfo = pair.Value; var buildAssetInfo = pair.Value;
if (buildAssetInfo.IsCollectAsset) if (buildAssetInfo.IsCollectAsset)
@ -216,7 +169,7 @@ namespace YooAsset.Editor
if(redundancy.Check(buildAssetInfo.AssetPath)) if(redundancy.Check(buildAssetInfo.AssetPath))
{ {
undependentAssets.Add(buildAssetInfo); undependentAssets.Add(buildAssetInfo);
buildMapContext.RedundancyList.Add(buildAssetInfo.AssetPath); buildMapContext.Report.RedundancyList.Add(buildAssetInfo.AssetPath);
continue; continue;
} }
} }
@ -227,18 +180,18 @@ namespace YooAsset.Editor
if (AssetBundleCollectorSettingData.HasCollector(buildAssetInfo.AssetPath) == false) if (AssetBundleCollectorSettingData.HasCollector(buildAssetInfo.AssetPath) == false)
{ {
undependentAssets.Add(buildAssetInfo); undependentAssets.Add(buildAssetInfo);
buildMapContext.RedundancyList.Add(buildAssetInfo.AssetPath); buildMapContext.Report.RedundancyList.Add(buildAssetInfo.AssetPath);
} }
} }
} }
foreach (var assetInfo in undependentAssets) foreach (var assetInfo in undependentAssets)
{ {
buildAssets.Remove(assetInfo.AssetPath); buildAssetDic.Remove(assetInfo.AssetPath);
} }
// 4. 设置资源包名 // 4. 设置资源包名
progressValue = 0; progressValue = 0;
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssets) foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
{ {
var assetInfo = pair.Value; var assetInfo = pair.Value;
var bundleLabel = AssetBundleCollectorSettingData.GetBundleLabel(assetInfo.AssetPath); var bundleLabel = AssetBundleCollectorSettingData.GetBundleLabel(assetInfo.AssetPath);
@ -246,15 +199,14 @@ namespace YooAsset.Editor
assetInfo.SetBundleLabelAndVariant(bundleLabel, ResourceSettingData.Setting.RawFileVariant); assetInfo.SetBundleLabelAndVariant(bundleLabel, ResourceSettingData.Setting.RawFileVariant);
else else
assetInfo.SetBundleLabelAndVariant(bundleLabel, ResourceSettingData.Setting.AssetBundleFileVariant); assetInfo.SetBundleLabelAndVariant(bundleLabel, ResourceSettingData.Setting.AssetBundleFileVariant);
EditorTools.DisplayProgressBar("设置资源包名", ++progressValue, buildAssets.Count); EditorTools.DisplayProgressBar("设置资源包名", ++progressValue, buildAssetDic.Count);
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
// 4. 构建资源包 // 4. 构建资源包
var allAssets = buildAssets.Values.ToList(); var allAssets = buildAssetDic.Values.ToList();
if (allAssets.Count == 0) if (allAssets.Count == 0)
throw new Exception("构建的资源列表不能为空"); throw new Exception("构建的资源列表不能为空");
UnityEngine.Debug.Log($"构建的资源列表里总共有{allAssets.Count}个资源");
foreach (var assetInfo in allAssets) foreach (var assetInfo in allAssets)
{ {
buildMapContext.PackAsset(assetInfo); buildMapContext.PackAsset(assetInfo);
@ -285,7 +237,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private void CheckBuildMapContent(BuildMapContext buildMapContext) private void CheckBuildMapContent(BuildMapContext buildMapContext)
{ {
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.Report.BundleInfos)
{ {
// 注意:原生文件资源包只能包含一个原生文件 // 注意:原生文件资源包只能包含一个原生文件
bool isRawFile = bundleInfo.IsRawFile; bool isRawFile = bundleInfo.IsRawFile;