feat : the build report file add independ asset info

pull/229/head
hevinci 2023-12-26 11:30:19 +08:00
parent 4b68362fb8
commit 2838289650
9 changed files with 81 additions and 20 deletions

View File

@ -21,7 +21,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 未被依赖的资源列表 /// 未被依赖的资源列表
/// </summary> /// </summary>
public readonly List<AssetInfo> UndependAssets = new List<AssetInfo>(1000); public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
/// <summary> /// <summary>
/// 参与构建的资源总数 /// 参与构建的资源总数

View File

@ -107,8 +107,9 @@ namespace YooAsset.Editor
buildReport.BundleInfos.Add(reportBundleInfo); buildReport.BundleInfos.Add(reportBundleInfo);
} }
// 冗余资源列表 // 资源列表
buildReport.RedundancyAssets = new List<ReportRedundancyAsset>(buildMapContext.RedundancyInfos); buildReport.RedundancyAssets = new List<ReportRedundancyAsset>(buildMapContext.RedundancyInfos);
buildReport.IndependAssets = new List<ReportIndependAsset>(buildMapContext.IndependAssets);
// 序列化文件 // 序列化文件
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion); string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);

View File

@ -107,11 +107,13 @@ namespace YooAsset.Editor
{ {
if (buildAssetInfo.IsRedundancyAsset()) if (buildAssetInfo.IsRedundancyAsset())
{ {
var redundancyInfo = new ReportRedundancyAsset(); var redundancyAsset = new ReportRedundancyAsset();
redundancyInfo.AssetInfo = buildAssetInfo.AssetInfo; redundancyAsset.AssetPath = buildAssetInfo.AssetInfo.AssetPath;
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetInfo.AssetPath); redundancyAsset.AssetGUID = buildAssetInfo.AssetInfo.AssetGUID;
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount(); redundancyAsset.AssetType = buildAssetInfo.AssetInfo.AssetType.ToString();
context.RedundancyInfos.Add(redundancyInfo); redundancyAsset.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetInfo.AssetPath);
redundancyAsset.Number = buildAssetInfo.GetReferenceBundleCount();
context.RedundancyInfos.Add(redundancyAsset);
} }
} }
@ -179,7 +181,14 @@ namespace YooAsset.Editor
{ {
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetInfo.AssetPath}"); string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetInfo.AssetPath}");
BuildLogger.Warning(warning); BuildLogger.Warning(warning);
context.UndependAssets.Add(removeValue.AssetInfo);
var independAsset = new ReportIndependAsset();
independAsset.AssetPath = removeValue.AssetInfo.AssetPath;
independAsset.AssetGUID = removeValue.AssetInfo.AssetGUID;
independAsset.AssetType = removeValue.AssetInfo.AssetType.ToString();
independAsset.FileSize = FileUtility.GetFileSize(removeValue.AssetInfo.AssetPath);
context.IndependAssets.Add(independAsset);
allCollectAssets.Remove(removeValue); allCollectAssets.Remove(removeValue);
} }
} }

View File

@ -35,7 +35,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 未被依赖的资源列表 /// 未被依赖的资源列表
/// </summary> /// </summary>
public List<AssetInfo> UndependAssets = new List<AssetInfo>(); public List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>();
/// <summary> /// <summary>
/// 获取资源包信息类 /// 获取资源包信息类

View File

@ -0,0 +1,30 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
public class ReportIndependAsset
{
/// <summary>
/// 资源路径
/// </summary>
public string AssetPath;
/// <summary>
/// 资源GUID
/// </summary>
public string AssetGUID;
/// <summary>
/// 资源类型
/// </summary>
public string AssetType;
/// <summary>
/// 资源文件大小
/// </summary>
public long FileSize;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6f187b12ce298c0429119fcf194f2621
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -8,9 +8,19 @@ namespace YooAsset.Editor
public class ReportRedundancyAsset public class ReportRedundancyAsset
{ {
/// <summary> /// <summary>
/// 资源信息 /// 资源路径
/// </summary> /// </summary>
public AssetInfo AssetInfo; public string AssetPath;
/// <summary>
/// 资源GUID
/// </summary>
public string AssetGUID;
/// <summary>
/// 资源类型
/// </summary>
public string AssetType;
/// <summary> /// <summary>
/// 资源文件大小 /// 资源文件大小

View File

@ -89,7 +89,7 @@ namespace YooAsset.Editor
{ {
if (string.IsNullOrEmpty(_searchKeyWord) == false) if (string.IsNullOrEmpty(_searchKeyWord) == false)
{ {
if (redundancyInfo.AssetInfo.AssetPath.Contains(_searchKeyWord) == false) if (redundancyInfo.AssetPath.Contains(_searchKeyWord) == false)
continue; continue;
} }
result.Add(redundancyInfo); result.Add(redundancyInfo);
@ -99,16 +99,16 @@ namespace YooAsset.Editor
if (_sortMode == ESortMode.AssetPath) if (_sortMode == ESortMode.AssetPath)
{ {
if (_descendingSort) if (_descendingSort)
return result.OrderByDescending(a => a.AssetInfo.AssetPath).ToList(); return result.OrderByDescending(a => a.AssetPath).ToList();
else else
return result.OrderBy(a => a.AssetInfo.AssetPath).ToList(); return result.OrderBy(a => a.AssetPath).ToList();
} }
else if (_sortMode == ESortMode.AssetType) else if (_sortMode == ESortMode.AssetType)
{ {
if (_descendingSort) if (_descendingSort)
return result.OrderByDescending(a => a.AssetInfo.AssetType).ToList(); return result.OrderByDescending(a => a.AssetType).ToList();
else else
return result.OrderBy(a => a.AssetInfo.AssetType).ToList(); return result.OrderBy(a => a.AssetType).ToList();
} }
else if (_sortMode == ESortMode.FileSize) else if (_sortMode == ESortMode.FileSize)
{ {
@ -209,7 +209,7 @@ namespace YooAsset.Editor
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f; label.style.marginLeft = 3f;
label.style.flexGrow = 0; label.style.flexGrow = 0;
label.style.width = 125; label.style.width = 200;
element.Add(label); element.Add(label);
} }
@ -242,11 +242,11 @@ namespace YooAsset.Editor
// Asset Path // Asset Path
var label1 = element.Q<Label>("Label1"); var label1 = element.Q<Label>("Label1");
label1.text = redundancyInfo.AssetInfo.AssetPath; label1.text = redundancyInfo.AssetPath;
// Asset Type // Asset Type
var label2 = element.Q<Label>("Label2"); var label2 = element.Q<Label>("Label2");
label2.text = redundancyInfo.AssetInfo.AssetType.ToString(); label2.text = redundancyInfo.AssetType.ToString();
// File Size // File Size
var label3 = element.Q<Label>("Label3"); var label3 = element.Q<Label>("Label3");

View File

@ -2,7 +2,7 @@
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;"> <uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" /> <uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
<uie:ToolbarButton text="Asset Type" display-tooltip-when-elided="true" name="TopBar2" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" /> <uie:ToolbarButton text="Asset Type" display-tooltip-when-elided="true" name="TopBar2" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
<uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="TopBar3" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" /> <uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="TopBar3" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
<uie:ToolbarButton text="Redundancy Num" display-tooltip-when-elided="true" name="TopBar4" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" /> <uie:ToolbarButton text="Redundancy Num" display-tooltip-when-elided="true" name="TopBar4" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
</uie:Toolbar> </uie:Toolbar>