Update AssetBundleBuilder
parent
8ee06ccf76
commit
512093b0ba
|
@ -26,19 +26,44 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 冗余的资源列表
|
||||||
|
/// </summary>
|
||||||
|
public List<string> RedundancyAssetList = new List<string>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列化
|
/// 获取资源包信息类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
public ReportBundleInfo GetBundleInfo(string bundleName)
|
||||||
|
{
|
||||||
|
foreach (var bundleInfo in BundleInfos)
|
||||||
|
{
|
||||||
|
if (bundleInfo.BundleName == bundleName)
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
throw new Exception($"Not found bundle : {bundleName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源信息类
|
||||||
|
/// </summary>
|
||||||
|
public ReportAssetInfo GetAssetInfo(string assetPath)
|
||||||
|
{
|
||||||
|
foreach (var assetInfo in AssetInfos)
|
||||||
|
{
|
||||||
|
if (assetInfo.AssetPath == assetPath)
|
||||||
|
return assetInfo;
|
||||||
|
}
|
||||||
|
throw new Exception($"Not found asset : {assetPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void Serialize(string savePath, BuildReport buildReport)
|
public static void Serialize(string savePath, BuildReport buildReport)
|
||||||
{
|
{
|
||||||
string json = JsonUtility.ToJson(buildReport, true);
|
string json = JsonUtility.ToJson(buildReport, true);
|
||||||
FileUtility.CreateFile(savePath, json);
|
FileUtility.CreateFile(savePath, json);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 反序列化
|
|
||||||
/// </summary>
|
|
||||||
public static BuildReport Deserialize(string jsonData)
|
public static BuildReport Deserialize(string jsonData)
|
||||||
{
|
{
|
||||||
BuildReport report = JsonUtility.FromJson<BuildReport>(jsonData);
|
BuildReport report = JsonUtility.FromJson<BuildReport>(jsonData);
|
||||||
|
|
|
@ -13,17 +13,17 @@ namespace YooAsset.Editor
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属资源包
|
/// 所属资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string MainBundle;
|
public string MainBundle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源包
|
/// 依赖的资源包名称列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependBundles = new List<string>();
|
public List<string> DependBundles = new List<string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源列表
|
/// 依赖的资源路径列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependAssets = new List<string>();
|
public List<string> DependAssets = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,14 @@ namespace YooAsset.Editor
|
||||||
UnityEngine.Debug.Log($"拷贝Readme文件到:{destPath}");
|
UnityEngine.Debug.Log($"拷贝Readme文件到:{destPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 拷贝Report文件
|
||||||
|
{
|
||||||
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.ReportFileName}";
|
||||||
|
string destPath = $"{packageDirectory}/{ResourceSettingData.Setting.ReportFileName}";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
UnityEngine.Debug.Log($"拷贝Report文件到:{destPath}");
|
||||||
|
}
|
||||||
|
|
||||||
// 拷贝PatchManifest文件
|
// 拷贝PatchManifest文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.PatchManifestFileName}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.PatchManifestFileName}";
|
||||||
|
|
|
@ -77,9 +77,9 @@ 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.RedundancyAssetList.Count; i++)
|
||||||
{
|
{
|
||||||
string redundancyAssetPath = buildMapContext.RedundancyList[i];
|
string redundancyAssetPath = buildMapContext.RedundancyAssetList[i];
|
||||||
AppendData(content, redundancyAssetPath);
|
AppendData(content, redundancyAssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,9 @@ namespace YooAsset.Editor
|
||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 冗余资源列表
|
||||||
|
buildReport.RedundancyAssetList = buildMapContext.RedundancyAssetList;
|
||||||
|
|
||||||
// 删除旧文件
|
// 删除旧文件
|
||||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.ReportFileName}";
|
string filePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.ReportFileName}";
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余的资源列表
|
/// 冗余的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<string> RedundancyList = new List<string>(1000);
|
public readonly List<string> RedundancyAssetList = new List<string>(1000);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -201,7 +201,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.RedundancyAssetList.Add(buildAssetInfo.AssetPath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ 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.RedundancyAssetList.Add(buildAssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue