mirror of https://github.com/tuyoogame/YooAsset
Compare commits
No commits in common. "64e9734bbeb46c4a8b50cfcc20aa5cec9864213b" and "82c57c382f4e909d3f12e541d08f239f7f8e78e1" have entirely different histories.
64e9734bbe
...
82c57c382f
|
@ -272,7 +272,7 @@ namespace YooAsset.Editor
|
||||||
packageData.ProviderInfos.Sort();
|
packageData.ProviderInfos.Sort();
|
||||||
foreach (var providerInfo in packageData.ProviderInfos)
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
providerInfo.DependBundles.Sort();
|
providerInfo.DependBundleInfos.Sort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
private class ProviderTableData : DefaultTableData
|
private class ProviderTableData : DefaultTableData
|
||||||
{
|
{
|
||||||
public DebugPackageData PackageData;
|
|
||||||
public DebugProviderInfo ProviderInfo;
|
public DebugProviderInfo ProviderInfo;
|
||||||
}
|
}
|
||||||
private class DependTableData : DefaultTableData
|
private class DependTableData : DefaultTableData
|
||||||
|
@ -206,7 +205,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
var providerTableData = data as ProviderTableData;
|
var providerTableData = data as ProviderTableData;
|
||||||
if (providerTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString())
|
if(providerTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString())
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = new StyleColor(Color.white);
|
textColor = new StyleColor(Color.white);
|
||||||
|
@ -310,7 +309,6 @@ namespace YooAsset.Editor
|
||||||
foreach (var providerInfo in packageData.ProviderInfos)
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
var rowData = new ProviderTableData();
|
var rowData = new ProviderTableData();
|
||||||
rowData.PackageData = packageData;
|
|
||||||
rowData.ProviderInfo = providerInfo;
|
rowData.ProviderInfo = providerInfo;
|
||||||
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
||||||
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
|
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
|
||||||
|
@ -370,14 +368,12 @@ namespace YooAsset.Editor
|
||||||
private void OnProviderTableViewSelectionChanged(ITableData data)
|
private void OnProviderTableViewSelectionChanged(ITableData data)
|
||||||
{
|
{
|
||||||
var providerTableData = data as ProviderTableData;
|
var providerTableData = data as ProviderTableData;
|
||||||
DebugPackageData packageData = providerTableData.PackageData;
|
|
||||||
DebugProviderInfo providerInfo = providerTableData.ProviderInfo;
|
DebugProviderInfo providerInfo = providerTableData.ProviderInfo;
|
||||||
|
|
||||||
// 填充依赖数据
|
// 填充依赖数据
|
||||||
var sourceDatas = new List<ITableData>(providerInfo.DependBundles.Count);
|
var sourceDatas = new List<ITableData>(providerInfo.DependBundleInfos.Count);
|
||||||
foreach (var bundleName in providerInfo.DependBundles)
|
foreach (var dependBundleInfo in providerInfo.DependBundleInfos)
|
||||||
{
|
{
|
||||||
var dependBundleInfo = packageData.GetBundleInfo(bundleName);
|
|
||||||
var rowData = new DependTableData();
|
var rowData = new DependTableData();
|
||||||
rowData.BundleInfo = dependBundleInfo;
|
rowData.BundleInfo = dependBundleInfo;
|
||||||
rowData.AddStringValueCell("DependBundles", dependBundleInfo.BundleName);
|
rowData.AddStringValueCell("DependBundles", dependBundleInfo.BundleName);
|
||||||
|
|
|
@ -13,24 +13,19 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
private class BundleTableData : DefaultTableData
|
private class BundleTableData : DefaultTableData
|
||||||
{
|
{
|
||||||
public DebugPackageData PackageData;
|
public string PackageName;
|
||||||
public DebugBundleInfo BundleInfo;
|
public DebugBundleInfo BundleInfo;
|
||||||
}
|
}
|
||||||
private class UsingTableData : DefaultTableData
|
private class UsingTableData : DefaultTableData
|
||||||
{
|
{
|
||||||
public DebugProviderInfo ProviderInfo;
|
public DebugProviderInfo ProviderInfo;
|
||||||
}
|
}
|
||||||
private class ReferenceTableData : DefaultTableData
|
|
||||||
{
|
|
||||||
public DebugBundleInfo BundleInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private TableView _bundleTableView;
|
private TableView _bundleTableView;
|
||||||
private TableView _usingTableView;
|
private TableView _usingTableView;
|
||||||
private TableView _referenceTableView;
|
|
||||||
|
|
||||||
private DebugReport _debugReport;
|
private DebugReport _debugReport;
|
||||||
private List<ITableData> _sourceDatas;
|
private List<ITableData> _sourceDatas;
|
||||||
|
@ -49,25 +44,20 @@ namespace YooAsset.Editor
|
||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源包列表
|
// 资源包列表
|
||||||
_bundleTableView = _root.Q<TableView>("BundleTableView");
|
_bundleTableView = _root.Q<TableView>("TopTableView");
|
||||||
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||||
CreateBundleTableViewColumns();
|
CreateBundleTableViewColumns();
|
||||||
|
|
||||||
// 使用列表
|
// 使用列表
|
||||||
_usingTableView = _root.Q<TableView>("UsingTableView");
|
_usingTableView = _root.Q<TableView>("BottomTableView");
|
||||||
CreateUsingTableViewColumns();
|
CreateUsingTableViewColumns();
|
||||||
|
|
||||||
// 引用列表
|
|
||||||
_referenceTableView = _root.Q<TableView>("ReferenceTableView");
|
|
||||||
CreateReferenceTableViewColumns();
|
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
#if UNITY_2020_3_OR_NEWER
|
||||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||||
topGroup.style.minHeight = 100;
|
topGroup.style.minHeight = 100;
|
||||||
bottomGroup.style.minHeight = 100f;
|
bottomGroup.style.minHeight = 100f;
|
||||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||||
PanelSplitView.SplitVerticalPanel(bottomGroup, _usingTableView, _referenceTableView);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
private void CreateBundleTableViewColumns()
|
private void CreateBundleTableViewColumns()
|
||||||
|
@ -279,79 +269,6 @@ namespace YooAsset.Editor
|
||||||
_usingTableView.AddColumn(column);
|
_usingTableView.AddColumn(column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void CreateReferenceTableViewColumns()
|
|
||||||
{
|
|
||||||
// BundleName
|
|
||||||
{
|
|
||||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
|
||||||
columnStyle.Stretchable = true;
|
|
||||||
columnStyle.Searchable = true;
|
|
||||||
columnStyle.Sortable = true;
|
|
||||||
var column = new TableColumn("ReferenceBundle", "Reference Bundle", columnStyle);
|
|
||||||
column.MakeCell = () =>
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
return label;
|
|
||||||
};
|
|
||||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
|
||||||
{
|
|
||||||
var infoLabel = element as Label;
|
|
||||||
infoLabel.text = (string)cell.GetDisplayObject();
|
|
||||||
};
|
|
||||||
_referenceTableView.AddColumn(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
// RefCount
|
|
||||||
{
|
|
||||||
var columnStyle = new ColumnStyle(100);
|
|
||||||
columnStyle.Stretchable = false;
|
|
||||||
columnStyle.Searchable = false;
|
|
||||||
columnStyle.Sortable = true;
|
|
||||||
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
|
|
||||||
column.MakeCell = () =>
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
return label;
|
|
||||||
};
|
|
||||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
|
||||||
{
|
|
||||||
var infoLabel = element as Label;
|
|
||||||
infoLabel.text = (string)cell.GetDisplayObject();
|
|
||||||
};
|
|
||||||
_referenceTableView.AddColumn(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Status
|
|
||||||
{
|
|
||||||
var columnStyle = new ColumnStyle(100);
|
|
||||||
columnStyle.Stretchable = false;
|
|
||||||
columnStyle.Searchable = false;
|
|
||||||
columnStyle.Sortable = true;
|
|
||||||
var column = new TableColumn("Status", "Status", columnStyle);
|
|
||||||
column.MakeCell = () =>
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
return label;
|
|
||||||
};
|
|
||||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
|
||||||
{
|
|
||||||
StyleColor textColor;
|
|
||||||
var feferenceTableData = data as ReferenceTableData;
|
|
||||||
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed)
|
|
||||||
textColor = new StyleColor(Color.yellow);
|
|
||||||
else
|
|
||||||
textColor = new StyleColor(Color.white);
|
|
||||||
|
|
||||||
var infoLabel = element as Label;
|
|
||||||
infoLabel.text = (string)cell.GetDisplayObject();
|
|
||||||
infoLabel.style.color = textColor;
|
|
||||||
};
|
|
||||||
_referenceTableView.AddColumn(column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 填充页面数据
|
/// 填充页面数据
|
||||||
|
@ -363,16 +280,22 @@ namespace YooAsset.Editor
|
||||||
// 清空旧数据
|
// 清空旧数据
|
||||||
_bundleTableView.ClearAll(false, true);
|
_bundleTableView.ClearAll(false, true);
|
||||||
_usingTableView.ClearAll(false, true);
|
_usingTableView.ClearAll(false, true);
|
||||||
_referenceTableView.ClearAll(false, true);
|
|
||||||
|
|
||||||
// 填充数据源
|
// 填充数据源
|
||||||
_sourceDatas = new List<ITableData>(1000);
|
_sourceDatas = new List<ITableData>(1000);
|
||||||
foreach (var packageData in debugReport.PackageDatas)
|
foreach (var packageData in debugReport.PackageDatas)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in packageData.BundleInfos)
|
var tempDic = new HashSet<string>();
|
||||||
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
|
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||||
|
{
|
||||||
|
if (tempDic.Contains(bundleInfo.BundleName) == false)
|
||||||
|
{
|
||||||
|
tempDic.Add(bundleInfo.BundleName);
|
||||||
|
|
||||||
var rowData = new BundleTableData();
|
var rowData = new BundleTableData();
|
||||||
rowData.PackageData = packageData;
|
rowData.PackageName = packageData.PackageName;
|
||||||
rowData.BundleInfo = bundleInfo;
|
rowData.BundleInfo = bundleInfo;
|
||||||
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
||||||
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
||||||
|
@ -381,6 +304,8 @@ namespace YooAsset.Editor
|
||||||
_sourceDatas.Add(rowData);
|
_sourceDatas.Add(rowData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
_bundleTableView.itemsSource = _sourceDatas;
|
_bundleTableView.itemsSource = _sourceDatas;
|
||||||
|
|
||||||
// 重建视图
|
// 重建视图
|
||||||
|
@ -397,8 +322,6 @@ namespace YooAsset.Editor
|
||||||
_bundleTableView.RebuildView();
|
_bundleTableView.RebuildView();
|
||||||
_usingTableView.ClearAll(false, true);
|
_usingTableView.ClearAll(false, true);
|
||||||
_usingTableView.RebuildView();
|
_usingTableView.RebuildView();
|
||||||
_referenceTableView.ClearAll(false, true);
|
|
||||||
_referenceTableView.RebuildView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -432,17 +355,19 @@ namespace YooAsset.Editor
|
||||||
private void OnBundleTableViewSelectionChanged(ITableData data)
|
private void OnBundleTableViewSelectionChanged(ITableData data)
|
||||||
{
|
{
|
||||||
var bundleTableData = data as BundleTableData;
|
var bundleTableData = data as BundleTableData;
|
||||||
var packageData = bundleTableData.PackageData;
|
|
||||||
var selectBundleInfo = bundleTableData.BundleInfo;
|
|
||||||
|
|
||||||
// 填充UsingTableView
|
// 填充依赖数据
|
||||||
{
|
|
||||||
var sourceDatas = new List<ITableData>(1000);
|
var sourceDatas = new List<ITableData>(1000);
|
||||||
|
foreach (var packageData in _debugReport.PackageDatas)
|
||||||
|
{
|
||||||
|
if (packageData.PackageName != bundleTableData.PackageName)
|
||||||
|
continue;
|
||||||
|
|
||||||
foreach (var providerInfo in packageData.ProviderInfos)
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
foreach (var dependBundleName in providerInfo.DependBundles)
|
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||||
{
|
{
|
||||||
if (dependBundleName == selectBundleInfo.BundleName)
|
if (bundleInfo.BundleName == bundleTableData.BundleInfo.BundleName)
|
||||||
{
|
{
|
||||||
var rowData = new UsingTableData();
|
var rowData = new UsingTableData();
|
||||||
rowData.ProviderInfo = providerInfo;
|
rowData.ProviderInfo = providerInfo;
|
||||||
|
@ -456,27 +381,10 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_usingTableView.itemsSource = sourceDatas;
|
_usingTableView.itemsSource = sourceDatas;
|
||||||
_usingTableView.RebuildView();
|
_usingTableView.RebuildView();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 填充ReferenceTableView
|
|
||||||
{
|
|
||||||
var sourceDatas = new List<ITableData>(1000);
|
|
||||||
foreach (string referenceBundleName in selectBundleInfo.ReferenceBundles)
|
|
||||||
{
|
|
||||||
var bundleInfo = packageData.GetBundleInfo(referenceBundleName);
|
|
||||||
var rowData = new ReferenceTableData();
|
|
||||||
rowData.BundleInfo = bundleInfo;
|
|
||||||
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
|
||||||
rowData.AddLongValueCell("RefCount", bundleInfo.RefCount);
|
|
||||||
rowData.AddStringValueCell("Status", bundleInfo.Status.ToString());
|
|
||||||
sourceDatas.Add(rowData);
|
|
||||||
}
|
|
||||||
_referenceTableView.itemsSource = sourceDatas;
|
|
||||||
_referenceTableView.RebuildView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -1,9 +1,8 @@
|
||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<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;">
|
||||||
<YooAsset.Editor.TableView name="BundleTableView" />
|
<YooAsset.Editor.TableView name="TopTableView" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 400px; 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: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; 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: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<YooAsset.Editor.TableView name="UsingTableView" />
|
<YooAsset.Editor.TableView name="BottomTableView" />
|
||||||
<YooAsset.Editor.TableView name="ReferenceTableView" />
|
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|
|
@ -22,11 +22,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EOperationStatus Status;
|
public EOperationStatus Status;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 谁引用了该资源包
|
|
||||||
/// </summary>
|
|
||||||
public List<string> ReferenceBundles;
|
|
||||||
|
|
||||||
public int CompareTo(DebugBundleInfo other)
|
public int CompareTo(DebugBundleInfo other)
|
||||||
{
|
{
|
||||||
return Compare(this, other);
|
return Compare(this, other);
|
||||||
|
|
|
@ -17,44 +17,5 @@ namespace YooAsset
|
||||||
/// 调试数据列表
|
/// 调试数据列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
|
public List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 调试数据列表
|
|
||||||
/// </summary>
|
|
||||||
public List<DebugBundleInfo> BundleInfos = new List<DebugBundleInfo>(1000);
|
|
||||||
|
|
||||||
|
|
||||||
[NonSerialized]
|
|
||||||
public Dictionary<string, DebugBundleInfo> BundleInfoDic = new Dictionary<string, DebugBundleInfo>();
|
|
||||||
private bool _isParse = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取调试资源包信息类
|
|
||||||
/// </summary>
|
|
||||||
public DebugBundleInfo GetBundleInfo(string bundleName)
|
|
||||||
{
|
|
||||||
// 解析数据
|
|
||||||
if (_isParse == false)
|
|
||||||
{
|
|
||||||
_isParse = true;
|
|
||||||
foreach (var bundleInfo in BundleInfos)
|
|
||||||
{
|
|
||||||
if (BundleInfoDic.ContainsKey(bundleInfo.BundleName) == false)
|
|
||||||
{
|
|
||||||
BundleInfoDic.Add(bundleInfo.BundleName, bundleInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BundleInfoDic.TryGetValue(bundleName, out DebugBundleInfo value))
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogError($"Can not found {nameof(DebugBundleInfo)} : {bundleName}");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,7 +45,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源包列表
|
/// 依赖的资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependBundles;
|
public List<DebugBundleInfo> DependBundleInfos;
|
||||||
|
|
||||||
public int CompareTo(DebugProviderInfo other)
|
public int CompareTo(DebugProviderInfo other)
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<DebugPackageData> PackageDatas = new List<DebugPackageData>(10);
|
public List<DebugPackageData> PackageDatas = new List<DebugPackageData>(10);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列化
|
/// 序列化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -14,13 +14,11 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ResourceManager _resManager;
|
private readonly ResourceManager _resManager;
|
||||||
private readonly int _loopCount;
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal UnloadUnusedAssetsOperation(ResourceManager resourceManager, int loopCount)
|
internal UnloadUnusedAssetsOperation(ResourceManager resourceManager)
|
||||||
{
|
{
|
||||||
_resManager = resourceManager;
|
_resManager = resourceManager;
|
||||||
_loopCount = loopCount;
|
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
|
@ -32,32 +30,6 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.UnloadUnused)
|
if (_steps == ESteps.UnloadUnused)
|
||||||
{
|
|
||||||
for (int i = 0; i < _loopCount; i++)
|
|
||||||
{
|
|
||||||
LoopUnloadUnused();
|
|
||||||
}
|
|
||||||
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal override void InternalWaitForAsyncComplete()
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if (ExecuteWhileDone())
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 说明:资源包之间会有深层的依赖链表,需要多次迭代才可以在单帧内卸载!
|
|
||||||
/// </summary>
|
|
||||||
private void LoopUnloadUnused()
|
|
||||||
{
|
{
|
||||||
var removeList = new List<LoadBundleFileOperation>(_resManager.LoaderDic.Count);
|
var removeList = new List<LoadBundleFileOperation>(_resManager.LoaderDic.Count);
|
||||||
|
|
||||||
|
@ -83,6 +55,21 @@ namespace YooAsset
|
||||||
loader.DestroyLoader();
|
loader.DestroyLoader();
|
||||||
_resManager.LoaderDic.Remove(bundleName);
|
_resManager.LoaderDic.Remove(bundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal override void InternalWaitForAsyncComplete()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (ExecuteWhileDone())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -286,7 +286,7 @@ namespace YooAsset
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 调试信息
|
#region 调试信息相关
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 出生的场景
|
/// 出生的场景
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -341,15 +341,16 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包的调试信息列表
|
/// 获取资源包的调试信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal List<string> GetDebugDependBundles()
|
internal void GetBundleDebugInfos(List<DebugBundleInfo> output)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>(_bundleLoaders.Count);
|
|
||||||
foreach (var bundleLoader in _bundleLoaders)
|
foreach (var bundleLoader in _bundleLoaders)
|
||||||
{
|
{
|
||||||
var packageBundle = bundleLoader.LoadBundleInfo.Bundle;
|
var bundleInfo = new DebugBundleInfo();
|
||||||
result.Add(packageBundle.BundleName);
|
bundleInfo.BundleName = bundleLoader.LoadBundleInfo.Bundle.BundleName;
|
||||||
|
bundleInfo.RefCount = bundleLoader.RefCount;
|
||||||
|
bundleInfo.Status = bundleLoader.Status;
|
||||||
|
output.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,15 +360,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 调试信息
|
#region 调试信息
|
||||||
internal DebugPackageData GetDebugPackageData()
|
internal List<DebugProviderInfo> GetDebugReportInfos()
|
||||||
{
|
|
||||||
DebugPackageData data = new DebugPackageData();
|
|
||||||
data.PackageName = PackageName;
|
|
||||||
data.ProviderInfos = GetDebugProviderInfos();
|
|
||||||
data.BundleInfos = GetDebugBundleInfos();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
internal List<DebugProviderInfo> GetDebugProviderInfos()
|
|
||||||
{
|
{
|
||||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(ProviderDic.Count);
|
List<DebugProviderInfo> result = new List<DebugProviderInfo>(ProviderDic.Count);
|
||||||
foreach (var provider in ProviderDic.Values)
|
foreach (var provider in ProviderDic.Values)
|
||||||
|
@ -380,38 +372,12 @@ namespace YooAsset
|
||||||
providerInfo.LoadingTime = provider.LoadingTime;
|
providerInfo.LoadingTime = provider.LoadingTime;
|
||||||
providerInfo.RefCount = provider.RefCount;
|
providerInfo.RefCount = provider.RefCount;
|
||||||
providerInfo.Status = provider.Status.ToString();
|
providerInfo.Status = provider.Status.ToString();
|
||||||
providerInfo.DependBundles = provider.GetDebugDependBundles();
|
providerInfo.DependBundleInfos = new List<DebugBundleInfo>();
|
||||||
|
provider.GetBundleDebugInfos(providerInfo.DependBundleInfos);
|
||||||
result.Add(providerInfo);
|
result.Add(providerInfo);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal List<DebugBundleInfo> GetDebugBundleInfos()
|
|
||||||
{
|
|
||||||
List<DebugBundleInfo> result = new List<DebugBundleInfo>(LoaderDic.Values.Count);
|
|
||||||
foreach (var bundleLoader in LoaderDic.Values)
|
|
||||||
{
|
|
||||||
var packageBundle = bundleLoader.LoadBundleInfo.Bundle;
|
|
||||||
var bundleInfo = new DebugBundleInfo();
|
|
||||||
bundleInfo.BundleName = packageBundle.BundleName;
|
|
||||||
bundleInfo.RefCount = bundleLoader.RefCount;
|
|
||||||
bundleInfo.Status = bundleLoader.Status;
|
|
||||||
bundleInfo.ReferenceBundles = FilterReferenceBundles(packageBundle);
|
|
||||||
result.Add(bundleInfo);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
internal List<string> FilterReferenceBundles(PackageBundle packageBundle)
|
|
||||||
{
|
|
||||||
// 注意:引用的资源包不一定在内存中,所以需要过滤
|
|
||||||
var referenceBundles = packageBundle.GetDebugReferenceBundles();
|
|
||||||
List<string> result = new List<string>(referenceBundles.Count);
|
|
||||||
foreach (var bundleName in referenceBundles)
|
|
||||||
{
|
|
||||||
if (LoaderDic.ContainsKey(bundleName))
|
|
||||||
result.Add(bundleName);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -120,7 +120,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void InitBundle(PackageManifest manifest)
|
public void InitBundle(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
_mainfest = manifest;
|
|
||||||
_bundleType = manifest.BuildBundleType;
|
_bundleType = manifest.BuildBundleType;
|
||||||
_fileExtension = ManifestTools.GetRemoteBundleFileExtension(BundleName);
|
_fileExtension = ManifestTools.GetRemoteBundleFileExtension(BundleName);
|
||||||
_fileName = ManifestTools.GetRemoteBundleFileName(manifest.OutputNameStyle, BundleName, _fileExtension, FileHash);
|
_fileName = ManifestTools.GetRemoteBundleFileName(manifest.OutputNameStyle, BundleName, _fileExtension, FileHash);
|
||||||
|
@ -178,23 +177,5 @@ namespace YooAsset
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 调试信息
|
|
||||||
private PackageManifest _mainfest;
|
|
||||||
private List<string> _debugReferenceBundles;
|
|
||||||
public List<string> GetDebugReferenceBundles()
|
|
||||||
{
|
|
||||||
if (_debugReferenceBundles == null)
|
|
||||||
{
|
|
||||||
_debugReferenceBundles = new List<string>(ReferenceBundleIDs.Count);
|
|
||||||
foreach (int bundleID in ReferenceBundleIDs)
|
|
||||||
{
|
|
||||||
var packageBundle = _mainfest.BundleList[bundleID];
|
|
||||||
_debugReferenceBundles.Add(packageBundle.BundleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _debugReferenceBundles;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -339,11 +339,10 @@ namespace YooAsset
|
||||||
/// 回收不再使用的资源
|
/// 回收不再使用的资源
|
||||||
/// 说明:卸载引用计数为零的资源
|
/// 说明:卸载引用计数为零的资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="loopCount">循环迭代次数</param>
|
public UnloadUnusedAssetsOperation UnloadUnusedAssetsAsync()
|
||||||
public UnloadUnusedAssetsOperation UnloadUnusedAssetsAsync(int loopCount = 10)
|
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
var operation = new UnloadUnusedAssetsOperation(_resourceManager, loopCount);
|
var operation = new UnloadUnusedAssetsOperation(_resourceManager);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -1147,7 +1146,10 @@ namespace YooAsset
|
||||||
#region 调试信息
|
#region 调试信息
|
||||||
internal DebugPackageData GetDebugPackageData()
|
internal DebugPackageData GetDebugPackageData()
|
||||||
{
|
{
|
||||||
return _resourceManager.GetDebugPackageData();
|
DebugPackageData data = new DebugPackageData();
|
||||||
|
data.PackageName = PackageName;
|
||||||
|
data.ProviderInfos = _resourceManager.GetDebugReportInfos();
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@ internal class SceneBattle : MonoBehaviour
|
||||||
_windowHandle.InstantiateSync(CanvasDesktop.transform);
|
_windowHandle.InstantiateSync(CanvasDesktop.transform);
|
||||||
|
|
||||||
// 加载背景音乐
|
// 加载背景音乐
|
||||||
_musicHandle = YooAssets.LoadAssetAsync<AudioClip>("music_background");
|
var package = YooAssets.GetPackage("DefaultPackage");
|
||||||
|
_musicHandle = package.LoadAssetAsync<AudioClip>("music_background");
|
||||||
yield return _musicHandle;
|
yield return _musicHandle;
|
||||||
|
|
||||||
// 播放背景音乐
|
// 播放背景音乐
|
||||||
|
@ -28,11 +29,6 @@ internal class SceneBattle : MonoBehaviour
|
||||||
audioSource.clip = _musicHandle.AssetObject as AudioClip;
|
audioSource.clip = _musicHandle.AssetObject as AudioClip;
|
||||||
audioSource.Play();
|
audioSource.Play();
|
||||||
|
|
||||||
// 切换场景的时候释放资源
|
|
||||||
var package = YooAssets.GetPackage("DefaultPackage");
|
|
||||||
var operation = package.UnloadUnusedAssetsAsync();
|
|
||||||
yield return operation;
|
|
||||||
|
|
||||||
_battleRoom = new BattleRoom();
|
_battleRoom = new BattleRoom();
|
||||||
_battleRoom.IntRoom();
|
_battleRoom.IntRoom();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,6 @@ public class SceneHome : MonoBehaviour
|
||||||
_windowHandle = YooAssets.LoadAssetAsync<GameObject>("UIHome");
|
_windowHandle = YooAssets.LoadAssetAsync<GameObject>("UIHome");
|
||||||
yield return _windowHandle;
|
yield return _windowHandle;
|
||||||
_windowHandle.InstantiateSync(CanvasDesktop.transform);
|
_windowHandle.InstantiateSync(CanvasDesktop.transform);
|
||||||
|
|
||||||
// 切换场景的时候释放资源
|
|
||||||
var package = YooAssets.GetPackage("DefaultPackage");
|
|
||||||
var operation = package.UnloadUnusedAssetsAsync();
|
|
||||||
yield return operation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
|
@ -29,5 +24,13 @@ public class SceneHome : MonoBehaviour
|
||||||
_windowHandle.Release();
|
_windowHandle.Release();
|
||||||
_windowHandle = null;
|
_windowHandle = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 切换场景的时候释放资源
|
||||||
|
if (YooAssets.Initialized)
|
||||||
|
{
|
||||||
|
var package = YooAssets.GetPackage("DefaultPackage");
|
||||||
|
var operation = package.UnloadUnusedAssetsAsync();
|
||||||
|
operation.WaitForAsyncComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue