mirror of https://github.com/tuyoogame/YooAsset
parent
d60b0ea0ea
commit
c9b775d8ff
|
@ -51,7 +51,7 @@ namespace YooAsset.Editor
|
||||||
/// 参与构建的资源列表
|
/// 参与构建的资源列表
|
||||||
/// 注意:不包含零依赖资源
|
/// 注意:不包含零依赖资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<BuildAssetInfo> BuildinAssets = new List<BuildAssetInfo>();
|
public readonly List<BuildAssetInfo> AllMainAssets = new List<BuildAssetInfo>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 补丁文件信息
|
/// 补丁文件信息
|
||||||
|
@ -76,9 +76,9 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
foreach (var asset in BuildinAssets)
|
foreach (var assetInfo in AllMainAssets)
|
||||||
{
|
{
|
||||||
if (asset.IsRawAsset)
|
if (assetInfo.IsRawAsset)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -113,7 +113,7 @@ namespace YooAsset.Editor
|
||||||
if (IsContainsAsset(assetInfo.AssetPath))
|
if (IsContainsAsset(assetInfo.AssetPath))
|
||||||
throw new System.Exception($"Asset is existed : {assetInfo.AssetPath}");
|
throw new System.Exception($"Asset is existed : {assetInfo.AssetPath}");
|
||||||
|
|
||||||
BuildinAssets.Add(assetInfo);
|
AllMainAssets.Add(assetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -121,7 +121,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsAsset(string assetPath)
|
public bool IsContainsAsset(string assetPath)
|
||||||
{
|
{
|
||||||
foreach (var assetInfo in BuildinAssets)
|
foreach (var assetInfo in AllMainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AssetPath == assetPath)
|
if (assetInfo.AssetPath == assetPath)
|
||||||
{
|
{
|
||||||
|
@ -136,8 +136,8 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetBundleTags()
|
public string[] GetBundleTags()
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>(BuildinAssets.Count);
|
List<string> result = new List<string>(AllMainAssets.Count);
|
||||||
foreach (var assetInfo in BuildinAssets)
|
foreach (var assetInfo in AllMainAssets)
|
||||||
{
|
{
|
||||||
foreach (var assetTag in assetInfo.BundleTags)
|
foreach (var assetTag in assetInfo.BundleTags)
|
||||||
{
|
{
|
||||||
|
@ -148,20 +148,43 @@ namespace YooAsset.Editor
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取该资源包内的所有资源(包括零依赖资源)
|
||||||
|
/// </summary>
|
||||||
|
public List<string> GetAllBuiltinAssetPaths()
|
||||||
|
{
|
||||||
|
var packAssets = GetAllMainAssetPaths();
|
||||||
|
List<string> result = new List<string>(packAssets);
|
||||||
|
foreach (var assetInfo in AllMainAssets)
|
||||||
|
{
|
||||||
|
if (assetInfo.AllDependAssetInfos == null)
|
||||||
|
continue;
|
||||||
|
foreach (var depend in assetInfo.AllDependAssetInfos)
|
||||||
|
{
|
||||||
|
if (depend.HasBundleName() == false)
|
||||||
|
{
|
||||||
|
if (result.Contains(depend.AssetPath) == false)
|
||||||
|
result.Add(depend.AssetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建的资源路径列表
|
/// 获取构建的资源路径列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetBuildinAssetPaths()
|
public string[] GetAllMainAssetPaths()
|
||||||
{
|
{
|
||||||
return BuildinAssets.Select(t => t.AssetPath).ToArray();
|
return AllMainAssets.Select(t => t.AssetPath).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有写入补丁清单的资源
|
/// 获取所有写入补丁清单的资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildAssetInfo[] GetAllBuildAssetInfos()
|
public BuildAssetInfo[] GetAllMainAssetInfos()
|
||||||
{
|
{
|
||||||
return BuildinAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
return AllMainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -173,7 +196,7 @@ namespace YooAsset.Editor
|
||||||
AssetBundleBuild build = new AssetBundleBuild();
|
AssetBundleBuild build = new AssetBundleBuild();
|
||||||
build.assetBundleName = BundleName;
|
build.assetBundleName = BundleName;
|
||||||
build.assetBundleVariant = string.Empty;
|
build.assetBundleVariant = string.Empty;
|
||||||
build.assetNames = GetBuildinAssetPaths();
|
build.assetNames = GetAllMainAssetPaths();
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,11 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int[] ReferenceIDs;
|
public int[] ReferenceIDs;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 该资源包内包含的所有资源
|
||||||
|
/// </summary>
|
||||||
|
public List<string> AllBuiltinAssets = new List<string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源分类标签的字符串
|
/// 获取资源分类标签的字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -32,10 +32,10 @@ namespace YooAsset.Editor
|
||||||
if (bundleInfo.IsRawFile)
|
if (bundleInfo.IsRawFile)
|
||||||
{
|
{
|
||||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
foreach (var assetInfo in bundleInfo.AllMainAssets)
|
||||||
{
|
{
|
||||||
if (buildAsset.IsRawAsset)
|
if (assetInfo.IsRawAsset)
|
||||||
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
EditorTools.CopyFile(assetInfo.AssetPath, dest, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ namespace YooAsset.Editor
|
||||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
var assetInfos = bundleInfo.GetAllBuildAssetInfos();
|
var assetInfos = bundleInfo.GetAllMainAssetInfos();
|
||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
{
|
{
|
||||||
PackageAsset packageAsset = new PackageAsset();
|
PackageAsset packageAsset = new PackageAsset();
|
||||||
|
|
|
@ -93,10 +93,11 @@ namespace YooAsset.Editor
|
||||||
reportBundleInfo.FileHash = packageBundle.FileHash;
|
reportBundleInfo.FileHash = packageBundle.FileHash;
|
||||||
reportBundleInfo.FileCRC = packageBundle.FileCRC;
|
reportBundleInfo.FileCRC = packageBundle.FileCRC;
|
||||||
reportBundleInfo.FileSize = packageBundle.FileSize;
|
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||||
reportBundleInfo.Tags = packageBundle.Tags;
|
|
||||||
reportBundleInfo.ReferenceIDs = packageBundle.ReferenceIDs;
|
|
||||||
reportBundleInfo.IsRawFile = packageBundle.IsRawFile;
|
reportBundleInfo.IsRawFile = packageBundle.IsRawFile;
|
||||||
reportBundleInfo.LoadMethod = (EBundleLoadMethod)packageBundle.LoadMethod;
|
reportBundleInfo.LoadMethod = (EBundleLoadMethod)packageBundle.LoadMethod;
|
||||||
|
reportBundleInfo.Tags = packageBundle.Tags;
|
||||||
|
reportBundleInfo.ReferenceIDs = packageBundle.ReferenceIDs;
|
||||||
|
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,11 +131,11 @@ namespace YooAsset.Editor
|
||||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
{
|
{
|
||||||
BuildAssetInfo findAssetInfo = null;
|
BuildAssetInfo findAssetInfo = null;
|
||||||
foreach (var buildinAsset in bundleInfo.BuildinAssets)
|
foreach (var assetInfo in bundleInfo.AllMainAssets)
|
||||||
{
|
{
|
||||||
if (buildinAsset.AssetPath == assetPath)
|
if (assetInfo.AssetPath == assetPath)
|
||||||
{
|
{
|
||||||
findAssetInfo = buildinAsset;
|
findAssetInfo = assetInfo;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,6 +151,15 @@ namespace YooAsset.Editor
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取该资源包内的所有资源(包括零依赖资源)
|
||||||
|
/// </summary>
|
||||||
|
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||||
|
{
|
||||||
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
|
return bundleInfo.GetAllBuiltinAssetPaths();
|
||||||
|
}
|
||||||
|
|
||||||
private int GetMainAssetCount(PackageManifest manifest)
|
private int GetMainAssetCount(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
return manifest.AssetList.Count;
|
return manifest.AssetList.Count;
|
||||||
|
|
|
@ -131,10 +131,10 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. 构建资源包
|
// 10. 构建资源包
|
||||||
var allBuildinAssets = buildAssetInfoDic.Values.ToList();
|
var allPackAssets = buildAssetInfoDic.Values.ToList();
|
||||||
if (allBuildinAssets.Count == 0)
|
if (allPackAssets.Count == 0)
|
||||||
throw new Exception("构建的资源列表不能为空");
|
throw new Exception("构建的资源列表不能为空");
|
||||||
foreach (var assetInfo in allBuildinAssets)
|
foreach (var assetInfo in allPackAssets)
|
||||||
{
|
{
|
||||||
context.PackAsset(assetInfo);
|
context.PackAsset(assetInfo);
|
||||||
}
|
}
|
||||||
|
@ -167,13 +167,13 @@ namespace YooAsset.Editor
|
||||||
bool isRawFile = bundleInfo.IsRawFile;
|
bool isRawFile = bundleInfo.IsRawFile;
|
||||||
if (isRawFile)
|
if (isRawFile)
|
||||||
{
|
{
|
||||||
if (bundleInfo.BuildinAssets.Count != 1)
|
if (bundleInfo.AllMainAssets.Count != 1)
|
||||||
throw new Exception($"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
throw new Exception($"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:原生文件不能被其它资源文件依赖
|
// 注意:原生文件不能被其它资源文件依赖
|
||||||
foreach (var assetInfo in bundleInfo.BuildinAssets)
|
foreach (var assetInfo in bundleInfo.AllMainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AllDependAssetInfos != null)
|
if (assetInfo.AllDependAssetInfos != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue