Update AssetBundleBuilder
This commit is contained in:
@@ -36,7 +36,7 @@ namespace YooAsset.Editor
|
||||
if (bundleInfo.IsRawFile)
|
||||
{
|
||||
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach(var buildAsset in bundleInfo.Assets)
|
||||
foreach(var buildAsset in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if(buildAsset.IsRawAsset)
|
||||
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -20,8 +18,10 @@ namespace YooAsset.Editor
|
||||
|
||||
private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, TaskGetBuildMap.BuildMapContext buildMapContext)
|
||||
{
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
|
||||
BuildReport buildReport = new BuildReport();
|
||||
|
||||
// 概述信息
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = 0;
|
||||
@@ -29,10 +29,8 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||
buildReport.Summary.ApplyRedundancy = buildParameters.Parameters.ApplyRedundancy;
|
||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||
|
||||
buildReport.Summary.IsCollectAllShaders = AssetBundleCollectorSettingData.Setting.IsCollectAllShaders;
|
||||
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||
|
||||
buildReport.Summary.IsForceRebuild = buildParameters.Parameters.IsForceRebuild;
|
||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||
@@ -41,14 +39,88 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.IsIgnoreTypeTreeChanges = buildParameters.Parameters.IsIgnoreTypeTreeChanges;
|
||||
buildReport.Summary.IsDisableLoadAssetByFileName = buildParameters.Parameters.IsDisableLoadAssetByFileName;
|
||||
|
||||
//buildReport.BundleInfos = buildMapContext.BundleInfos;
|
||||
buildReport.RedundancyList = buildMapContext.RedundancyList;
|
||||
// 资源对象列表
|
||||
buildReport.AssetInfos = new List<ReportAssetInfo>(patchManifest.AssetList.Count);
|
||||
foreach (var patchAsset in patchManifest.AssetList)
|
||||
{
|
||||
var mainBundle = patchManifest.BundleList[patchAsset.BundleID];
|
||||
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
||||
reportAssetInfo.AssetPath = patchAsset.AssetPath;
|
||||
reportAssetInfo.MainBundle = mainBundle.BundleName;
|
||||
reportAssetInfo.DependBundles = GetDependBundles(patchManifest, patchAsset);
|
||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, patchAsset.AssetPath);
|
||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||
}
|
||||
|
||||
// 资源包列表
|
||||
buildReport.BundleInfos = new List<ReportBundleInfo>(patchManifest.BundleList.Count);
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
||||
reportBundleInfo.BundleName = patchBundle.BundleName;
|
||||
reportBundleInfo.Hash = patchBundle.Hash;
|
||||
reportBundleInfo.CRC = patchBundle.CRC;
|
||||
reportBundleInfo.SizeBytes = patchBundle.SizeBytes;
|
||||
reportBundleInfo.Version = patchBundle.Version;
|
||||
reportBundleInfo.Tags = patchBundle.Tags;
|
||||
reportBundleInfo.Flags = patchBundle.Flags;
|
||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||
}
|
||||
|
||||
// 删除旧文件
|
||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.ReportFileName}";
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
// 序列化文件
|
||||
BuildReport.Serialize(filePath, buildReport);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的所有资源包
|
||||
/// </summary>
|
||||
private List<string> GetDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(patchAsset.DependIDs.Length);
|
||||
foreach(int index in patchAsset.DependIDs)
|
||||
{
|
||||
string dependBundleName = patchManifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
return dependBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// </summary>
|
||||
private List<string> GetDependAssets(TaskGetBuildMap.BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
if(buildMapContext.TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
BuildAssetInfo findAssetInfo = null;
|
||||
foreach(var buildinAsset in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if(buildinAsset.AssetPath == assetPath)
|
||||
{
|
||||
findAssetInfo = buildinAsset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (findAssetInfo == null)
|
||||
{
|
||||
throw new Exception($"Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach(var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found bundle : {bundleName}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace YooAsset.Editor
|
||||
List<BuildAssetInfo> result = new List<BuildAssetInfo>(BundleInfos.Count);
|
||||
foreach (var bundleInfo in BundleInfos)
|
||||
{
|
||||
result.AddRange(bundleInfo.Assets);
|
||||
result.AddRange(bundleInfo.BuildinAssets);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace YooAsset.Editor
|
||||
return TryGetBundleInfo(bundleFullName, out BuildBundleInfo bundleInfo);
|
||||
}
|
||||
|
||||
private bool TryGetBundleInfo(string bundleFullName, out BuildBundleInfo result)
|
||||
public bool TryGetBundleInfo(string bundleFullName, out BuildBundleInfo result)
|
||||
{
|
||||
foreach (var bundleInfo in BundleInfos)
|
||||
{
|
||||
@@ -188,6 +188,7 @@ namespace YooAsset.Editor
|
||||
if (buildAssetInfo.IsCollectAsset)
|
||||
continue;
|
||||
|
||||
// 零依赖资源
|
||||
if (buildAssetInfo.DependCount == 0)
|
||||
{
|
||||
undependentAssets.Add(buildAssetInfo);
|
||||
@@ -274,13 +275,13 @@ namespace YooAsset.Editor
|
||||
bool isRawFile = bundleInfo.IsRawFile;
|
||||
if (isRawFile)
|
||||
{
|
||||
if (bundleInfo.Assets.Count != 1)
|
||||
if (bundleInfo.BuildinAssets.Count != 1)
|
||||
throw new Exception("The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 注意:原生文件不能被其它资源文件依赖
|
||||
foreach (var assetInfo in bundleInfo.Assets)
|
||||
foreach (var assetInfo in bundleInfo.BuildinAssets)
|
||||
{
|
||||
if (assetInfo.AllDependAssetInfos != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user