refactor : editor code

This commit is contained in:
hevinci
2023-12-25 14:19:55 +08:00
parent 82b2a5cc20
commit e8e7696a4d
19 changed files with 250 additions and 195 deletions

View File

@@ -30,8 +30,12 @@ namespace YooAsset.Editor
/// <summary>
/// 冗余的资源列表
/// </summary>
public List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>();
public List<ReportRedundancyAsset> RedundancyAssets = new List<ReportRedundancyAsset>();
/// <summary>
/// 未被依赖的资源列表
/// </summary>
public List<AssetInfo> UndependAssets = new List<AssetInfo>();
/// <summary>
/// 获取资源包信息类

View File

@@ -5,23 +5,12 @@ using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
public class ReportRedundancyInfo
public class ReportRedundancyAsset
{
/// <summary>
/// 资源路径
/// 资源信息
/// </summary>
public string AssetPath;
/// <summary>
/// 资源类型
/// </summary>
public string AssetType;
/// <summary>
/// 资源GUID
/// 说明Meta文件记录的GUID
/// </summary>
public string AssetGUID;
public AssetInfo AssetInfo;
/// <summary>
/// 资源文件大小

View File

@@ -80,16 +80,16 @@ namespace YooAsset.Editor
_assetListView.Rebuild();
RefreshSortingSymbol();
}
private List<ReportRedundancyInfo> FilterAndSortViewItems()
private List<ReportRedundancyAsset> FilterAndSortViewItems()
{
List<ReportRedundancyInfo> result = new List<ReportRedundancyInfo>(_buildReport.RedundancyInfos.Count);
List<ReportRedundancyAsset> result = new List<ReportRedundancyAsset>(_buildReport.RedundancyAssets.Count);
// 过滤列表
foreach (var redundancyInfo in _buildReport.RedundancyInfos)
foreach (var redundancyInfo in _buildReport.RedundancyAssets)
{
if (string.IsNullOrEmpty(_searchKeyWord) == false)
{
if (redundancyInfo.AssetPath.Contains(_searchKeyWord) == false)
if (redundancyInfo.AssetInfo.AssetPath.Contains(_searchKeyWord) == false)
continue;
}
result.Add(redundancyInfo);
@@ -99,16 +99,16 @@ namespace YooAsset.Editor
if (_sortMode == ESortMode.AssetPath)
{
if (_descendingSort)
return result.OrderByDescending(a => a.AssetPath).ToList();
return result.OrderByDescending(a => a.AssetInfo.AssetPath).ToList();
else
return result.OrderBy(a => a.AssetPath).ToList();
return result.OrderBy(a => a.AssetInfo.AssetPath).ToList();
}
else if (_sortMode == ESortMode.AssetType)
{
if (_descendingSort)
return result.OrderByDescending(a => a.AssetType).ToList();
return result.OrderByDescending(a => a.AssetInfo.AssetType).ToList();
else
return result.OrderBy(a => a.AssetType).ToList();
return result.OrderBy(a => a.AssetInfo.AssetType).ToList();
}
else if (_sortMode == ESortMode.FileSize)
{
@@ -237,16 +237,16 @@ namespace YooAsset.Editor
}
private void BindAssetListViewItem(VisualElement element, int index)
{
var sourceData = _assetListView.itemsSource as List<ReportRedundancyInfo>;
var sourceData = _assetListView.itemsSource as List<ReportRedundancyAsset>;
var redundancyInfo = sourceData[index];
// Asset Path
var label1 = element.Q<Label>("Label1");
label1.text = redundancyInfo.AssetPath;
label1.text = redundancyInfo.AssetInfo.AssetPath;
// Asset Type
var label2 = element.Q<Label>("Label2");
label2.text = redundancyInfo.AssetType;
label2.text = redundancyInfo.AssetInfo.AssetType.ToString();
// File Size
var label3 = element.Q<Label>("Label3");