mirror of https://github.com/tuyoogame/YooAsset
parent
5254fb65ef
commit
985b05f29d
|
@ -8,6 +8,8 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildMapContext : IContextObject
|
public class BuildMapContext : IContextObject
|
||||||
{
|
{
|
||||||
|
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源总数
|
/// 参与构建的资源总数
|
||||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||||
|
@ -32,7 +34,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包列表
|
/// 资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<BuildBundleInfo> BundleInfos = new List<BuildBundleInfo>(1000);
|
public readonly List<BuildBundleInfo> BundleInfos = new List<BuildBundleInfo>(10000);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -44,7 +46,7 @@ namespace YooAsset.Editor
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
||||||
{
|
{
|
||||||
bundleInfo.PackAsset(assetInfo);
|
bundleInfo.PackAsset(assetInfo);
|
||||||
}
|
}
|
||||||
|
@ -53,6 +55,7 @@ namespace YooAsset.Editor
|
||||||
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
||||||
newBundleInfo.PackAsset(assetInfo);
|
newBundleInfo.PackAsset(assetInfo);
|
||||||
BundleInfos.Add(newBundleInfo);
|
BundleInfos.Add(newBundleInfo);
|
||||||
|
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +77,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetBuildinAssetPaths(string bundleName)
|
public string[] GetBuildinAssetPaths(string bundleName)
|
||||||
{
|
{
|
||||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
||||||
{
|
{
|
||||||
return bundleInfo.GetBuildinAssetPaths();
|
return bundleInfo.GetBuildinAssetPaths();
|
||||||
}
|
}
|
||||||
|
@ -100,21 +103,19 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsBundle(string bundleName)
|
public bool IsContainsBundle(string bundleName)
|
||||||
{
|
{
|
||||||
return TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo);
|
return _bundleInfoDic.ContainsKey(bundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetBundleInfo(string bundleName, out BuildBundleInfo result)
|
/// <summary>
|
||||||
|
/// 获取资源包信息,如果没找到返回NULL
|
||||||
|
/// </summary>
|
||||||
|
public BuildBundleInfo GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in BundleInfos)
|
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo result))
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName == bundleName)
|
return result;
|
||||||
{
|
|
||||||
result = bundleInfo;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result = null;
|
throw new Exception($"Not found bundle : {bundleName}");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -127,7 +127,7 @@ namespace YooAsset.Editor
|
||||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
if (buildMapContext.TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
{
|
{
|
||||||
BuildAssetInfo findAssetInfo = null;
|
BuildAssetInfo findAssetInfo = null;
|
||||||
foreach (var buildinAsset in bundleInfo.BuildinAssets)
|
foreach (var buildinAsset in bundleInfo.BuildinAssets)
|
||||||
|
@ -147,10 +147,6 @@ namespace YooAsset.Editor
|
||||||
result.Add(dependAssetInfo.AssetPath);
|
result.Add(dependAssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception($"Not found bundle : {bundleName}");
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,13 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 过滤掉原生Bundle
|
||||||
string[] mapBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
|
string[] mapBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证Bundle
|
||||||
List<string> exceptBundleList1 = buildedBundles.Except(mapBundles).ToList();
|
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
|
@ -51,7 +51,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证Bundle
|
||||||
List<string> exceptBundleList2 = mapBundles.Except(buildedBundles).ToList();
|
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
|
|
|
@ -35,13 +35,13 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
List<string> buildedBundles = buildResults.BundleInfos.Keys.ToList();
|
List<string> unityCreateBundles = buildResults.BundleInfos.Keys.ToList();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 过滤掉原生Bundle
|
||||||
List<string> expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
|
List<string> expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证Bundle
|
||||||
List<string> exceptBundleList1 = buildedBundles.Except(expectBundles).ToList();
|
List<string> exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
|
@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证Bundle
|
||||||
List<string> exceptBundleList2 = expectBundles.Except(buildedBundles).ToList();
|
List<string> exceptBundleList2 = expectBundles.Except(unityCreateBundles).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
|
|
Loading…
Reference in New Issue