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