diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs b/Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs
index 3b20b2a3..74aa27b7 100644
--- a/Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs
+++ b/Assets/YooAsset/Editor/AssetBundleDebugger/AssetBundleDebuggerWindow.cs
@@ -38,6 +38,11 @@ namespace YooAsset.Editor
/// 资源包视图
///
BundleView,
+
+ ///
+ /// 异步操作视图
+ ///
+ OperationView,
}
@@ -48,6 +53,7 @@ namespace YooAsset.Editor
private SliderInt _frameSlider;
private DebuggerAssetListViewer _assetListViewer;
private DebuggerBundleListViewer _bundleListViewer;
+ private DebuggerOperationListViewer _operationListViewer;
private EViewMode _viewMode;
private string _searchKeyWord;
@@ -85,6 +91,7 @@ namespace YooAsset.Editor
_viewModeMenu = root.Q("ViewModeMenu");
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
+ _viewModeMenu.menu.AppendAction(EViewMode.OperationView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.OperationView);
_viewModeMenu.text = EViewMode.AssetView.ToString();
// 搜索栏
@@ -121,6 +128,10 @@ namespace YooAsset.Editor
_bundleListViewer = new DebuggerBundleListViewer();
_bundleListViewer.InitViewer();
+ // 加载视图
+ _operationListViewer = new DebuggerOperationListViewer();
+ _operationListViewer.InitViewer();
+
// 显示视图
_viewMode = EViewMode.AssetView;
_assetListViewer.AttachParent(root);
@@ -207,6 +218,7 @@ namespace YooAsset.Editor
_currentPlayerSession.ClearDebugReport();
_assetListViewer.ClearView();
_bundleListViewer.ClearView();
+ _operationListViewer.ClearView();
}
}
@@ -242,6 +254,7 @@ namespace YooAsset.Editor
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
_assetListViewer.FillViewData(debugReport);
_bundleListViewer.FillViewData(debugReport);
+ _operationListViewer.FillViewData(debugReport);
}
}
@@ -288,6 +301,7 @@ namespace YooAsset.Editor
{
_assetListViewer.RebuildView(_searchKeyWord);
_bundleListViewer.RebuildView(_searchKeyWord);
+ _operationListViewer.RebuildView(_searchKeyWord);
}
}
private void OnViewModeMenuChange(DropdownMenuAction action)
@@ -303,11 +317,19 @@ namespace YooAsset.Editor
{
_assetListViewer.AttachParent(root);
_bundleListViewer.DetachParent();
+ _operationListViewer.DetachParent();
}
else if (viewMode == EViewMode.BundleView)
{
_assetListViewer.DetachParent();
_bundleListViewer.AttachParent(root);
+ _operationListViewer.DetachParent();
+ }
+ else if (viewMode == EViewMode.OperationView)
+ {
+ _assetListViewer.DetachParent();
+ _bundleListViewer.DetachParent();
+ _operationListViewer.AttachParent(root);
}
else
{
diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerAssetListViewer.cs b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerAssetListViewer.cs
index 6d5df657..7e33df81 100644
--- a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerAssetListViewer.cs
+++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerAssetListViewer.cs
@@ -126,13 +126,13 @@ namespace YooAsset.Editor
_providerTableView.AddColumn(column);
}
- // SpawnTime
+ // BeginTime
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
- var column = new TableColumn("SpawnTime", "Spawn Time", columnStyle);
+ var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
@@ -315,7 +315,7 @@ namespace YooAsset.Editor
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
- rowData.AddStringValueCell("SpawnTime", providerInfo.SpawnTime);
+ rowData.AddStringValueCell("BeginTime", providerInfo.BeginTime);
rowData.AddLongValueCell("LoadingTime", providerInfo.LoadingTime);
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
rowData.AddStringValueCell("Status", providerInfo.Status.ToString());
diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs
index 21902767..b21bb206 100644
--- a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs
+++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs
@@ -208,13 +208,13 @@ namespace YooAsset.Editor
_usingTableView.AddColumn(column);
}
- // SpawnTime
+ // BeginTime
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
- var column = new TableColumn("SpawnTime", "Spawn Time", columnStyle);
+ var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
@@ -448,7 +448,7 @@ namespace YooAsset.Editor
rowData.ProviderInfo = providerInfo;
rowData.AddStringValueCell("UsingAssets", providerInfo.AssetPath);
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
- rowData.AddStringValueCell("SpawnTime", providerInfo.SpawnTime);
+ rowData.AddStringValueCell("BeginTime", providerInfo.BeginTime);
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
rowData.AddStringValueCell("Status", providerInfo.Status);
sourceDatas.Add(rowData);
diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.cs b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.cs
new file mode 100644
index 00000000..0e8b3c9c
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.cs
@@ -0,0 +1,281 @@
+#if UNITY_2019_4_OR_NEWER
+using System.IO;
+using System.Linq;
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEngine;
+using UnityEditor.UIElements;
+using UnityEngine.UIElements;
+
+namespace YooAsset.Editor
+{
+ internal class DebuggerOperationListViewer
+ {
+ private class OperationTableData : DefaultTableData
+ {
+ public DebugPackageData PackageData;
+ public DebugOperationInfo OperationInfo;
+ }
+
+ private VisualTreeAsset _visualAsset;
+ private TemplateContainer _root;
+
+ private TableView _operationTableView;
+
+ private DebugReport _debugReport;
+ private List _sourceDatas;
+
+
+ ///
+ /// 初始化页面
+ ///
+ public void InitViewer()
+ {
+ // 加载布局文件
+ _visualAsset = UxmlLoader.LoadWindowUXML();
+ if (_visualAsset == null)
+ return;
+
+ _root = _visualAsset.CloneTree();
+ _root.style.flexGrow = 1f;
+
+ // 任务列表
+ _operationTableView = _root.Q("TopTableView");
+ CreateOperationTableViewColumns();
+ }
+ private void CreateOperationTableViewColumns()
+ {
+
+ // PackageName
+ {
+ var columnStyle = new ColumnStyle(200);
+ columnStyle.Stretchable = true;
+ columnStyle.Searchable = true;
+ columnStyle.Sortable = true;
+ columnStyle.Counter = true;
+ var column = new TableColumn("PackageName", "Package Name", 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();
+ };
+ _operationTableView.AddColumn(column);
+ }
+
+ // OperationName
+ {
+ var columnStyle = new ColumnStyle(300, 300, 600);
+ columnStyle.Stretchable = true;
+ columnStyle.Searchable = true;
+ columnStyle.Sortable = true;
+ columnStyle.Counter = true;
+ var column = new TableColumn("OperationName", "Operation Name", 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();
+ };
+ _operationTableView.AddColumn(column);
+ }
+
+ // Priority
+ {
+ var columnStyle = new ColumnStyle(100);
+ columnStyle.Stretchable = false;
+ columnStyle.Searchable = false;
+ columnStyle.Sortable = true;
+ var column = new TableColumn("Priority", "Priority", 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();
+ };
+ _operationTableView.AddColumn(column);
+ }
+
+ // Progress
+ {
+ var columnStyle = new ColumnStyle(100);
+ columnStyle.Stretchable = false;
+ columnStyle.Searchable = false;
+ columnStyle.Sortable = false;
+ var column = new TableColumn("Progress", "Progress", 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();
+ };
+ _operationTableView.AddColumn(column);
+ }
+
+ // BeginTime
+ {
+ var columnStyle = new ColumnStyle(100);
+ columnStyle.Stretchable = false;
+ columnStyle.Searchable = false;
+ columnStyle.Sortable = true;
+ var column = new TableColumn("BeginTime", "Begin Time", 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();
+ };
+ _operationTableView.AddColumn(column);
+ }
+
+ // ProcessTime
+ {
+ var columnStyle = new ColumnStyle(100);
+ columnStyle.Stretchable = false;
+ columnStyle.Searchable = false;
+ columnStyle.Sortable = true;
+ var column = new TableColumn("LoadingTime", "Loading Time", 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();
+ };
+ _operationTableView.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 operationTableData = data as OperationTableData;
+ if (operationTableData.OperationInfo.Status == EOperationStatus.Failed.ToString())
+ 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;
+ };
+ _operationTableView.AddColumn(column);
+ }
+ }
+
+ ///
+ /// 填充页面数据
+ ///
+ public void FillViewData(DebugReport debugReport)
+ {
+ _debugReport = debugReport;
+
+ // 清空旧数据
+ _operationTableView.ClearAll(false, true);
+
+ // 填充数据源
+ _sourceDatas = new List(1000);
+ foreach (var packageData in debugReport.PackageDatas)
+ {
+ foreach (var operationInfo in packageData.OperationInfos)
+ {
+ var rowData = new OperationTableData();
+ rowData.PackageData = packageData;
+ rowData.OperationInfo = operationInfo;
+ rowData.AddStringValueCell("PackageName", packageData.PackageName);
+ rowData.AddStringValueCell("OperationName", operationInfo.OperationName);
+ rowData.AddLongValueCell("Priority", operationInfo.Priority);
+ rowData.AddDoubleValueCell("Progress", operationInfo.Progress);
+ rowData.AddStringValueCell("BeginTime", operationInfo.BeginTime);
+ rowData.AddLongValueCell("LoadingTime", operationInfo.ProcessTime);
+ rowData.AddStringValueCell("Status", operationInfo.Status.ToString());
+ _sourceDatas.Add(rowData);
+ }
+ }
+ _operationTableView.itemsSource = _sourceDatas;
+
+ // 重建视图
+ RebuildView(null);
+ }
+
+ ///
+ /// 清空页面
+ ///
+ public void ClearView()
+ {
+ _debugReport = null;
+ _operationTableView.ClearAll(false, true);
+ RebuildView(null);
+ }
+
+ ///
+ /// 重建视图
+ ///
+ public void RebuildView(string searchKeyWord)
+ {
+ // 搜索匹配
+ DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
+
+ // 重建视图
+ _operationTableView.RebuildView();
+ }
+
+ ///
+ /// 挂接到父类页面上
+ ///
+ public void AttachParent(VisualElement parent)
+ {
+ parent.Add(_root);
+ }
+
+ ///
+ /// 从父类页面脱离开
+ ///
+ public void DetachParent()
+ {
+ _root.RemoveFromHierarchy();
+ }
+ }
+}
+#endif
\ No newline at end of file
diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.cs.meta b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.cs.meta
new file mode 100644
index 00000000..e8183660
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: faabdaf3787cba6438d2300f7f71e26f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.uxml b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.uxml
new file mode 100644
index 00000000..b4790493
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.uxml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.uxml.meta b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.uxml.meta
new file mode 100644
index 00000000..e7159e67
--- /dev/null
+++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerOperationListViewer.uxml.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 7147c7108cba1bb4dba3a2cfc758ad43
+ScriptedImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 2
+ userData:
+ assetBundleName:
+ assetBundleVariant:
+ script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
diff --git a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugOperationInfo.cs b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugOperationInfo.cs
new file mode 100644
index 00000000..886c8a43
--- /dev/null
+++ b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugOperationInfo.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace YooAsset
+{
+ [Serializable]
+ internal class DebugOperationInfo : IComparer, IComparable
+ {
+ ///
+ /// 任务名称
+ ///
+ public string OperationName;
+
+ ///
+ /// 优先级
+ ///
+ public uint Priority;
+
+ ///
+ /// 任务进度
+ ///
+ public float Progress;
+
+ ///
+ /// 任务开始的时间
+ ///
+ public string BeginTime;
+
+ ///
+ /// 处理耗时(单位:毫秒)
+ ///
+ public long ProcessTime;
+
+ ///
+ /// 任务状态
+ ///
+ public string Status;
+
+ public int CompareTo(DebugOperationInfo other)
+ {
+ return Compare(this, other);
+ }
+ public int Compare(DebugOperationInfo a, DebugOperationInfo b)
+ {
+ return string.CompareOrdinal(a.OperationName, b.OperationName);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugOperationInfo.cs.meta b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugOperationInfo.cs.meta
new file mode 100644
index 00000000..9c5b9c36
--- /dev/null
+++ b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugOperationInfo.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 942ce6ad7b4427d4d87a8a29c8b9371f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugPackageData.cs b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugPackageData.cs
index e2a28761..3360a165 100644
--- a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugPackageData.cs
+++ b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugPackageData.cs
@@ -13,15 +13,9 @@ namespace YooAsset
///
public string PackageName;
- ///
- /// 调试数据列表
- ///
public List ProviderInfos = new List(1000);
-
- ///
- /// 调试数据列表
- ///
public List BundleInfos = new List(1000);
+ public List OperationInfos = new List(1000);
[NonSerialized]
diff --git a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugProviderInfo.cs b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugProviderInfo.cs
index f6531d94..d80c62e8 100644
--- a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugProviderInfo.cs
+++ b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugProviderInfo.cs
@@ -23,9 +23,9 @@ namespace YooAsset
public string SpawnScene;
///
- /// 资源出生的时间
+ /// 资源加载开始时间
///
- public string SpawnTime;
+ public string BeginTime;
///
/// 加载耗时(单位:毫秒)
diff --git a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
index be1b4706..3cd23b28 100644
--- a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
+++ b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
@@ -24,12 +24,12 @@ namespace YooAsset
internal bool IsFinish { private set; get; } = false;
///
- /// 优先级
+ /// 任务优先级
///
public uint Priority { set; get; } = 0;
///
- /// 状态
+ /// 任务状态
///
public EOperationStatus Status { get; protected set; } = EOperationStatus.None;
@@ -139,6 +139,11 @@ namespace YooAsset
if (Status == EOperationStatus.None)
{
Status = EOperationStatus.Processing;
+
+ // 开始记录
+ DebugBeginRecording();
+
+ // 开始任务
InternalStart();
}
}
@@ -149,7 +154,13 @@ namespace YooAsset
internal void UpdateOperation()
{
if (IsDone == false)
+ {
+ // 更新记录
+ DebugUpdateRecording();
+
+ // 更新任务
InternalUpdate();
+ }
if (IsDone && IsFinish == false)
{
@@ -158,6 +169,9 @@ namespace YooAsset
// 进度百分百完成
Progress = 1f;
+ // 结束记录
+ DebugEndRecording();
+
//注意:如果完成回调内发生异常,会导致Task无限期等待
_callback?.Invoke(this);
@@ -235,6 +249,55 @@ namespace YooAsset
}
#region 调试信息
+ ///
+ /// 开始的时间
+ ///
+ public string BeginTime = string.Empty;
+
+ ///
+ /// 处理耗时(单位:毫秒)
+ ///
+ public long ProcessTime { protected set; get; }
+
+ // 加载耗时统计
+ private Stopwatch _watch = null;
+
+ [Conditional("DEBUG")]
+ private void DebugBeginRecording()
+ {
+ if (_watch == null)
+ {
+ BeginTime = SpawnTimeToString(UnityEngine.Time.realtimeSinceStartup);
+ _watch = Stopwatch.StartNew();
+ }
+ }
+
+ [Conditional("DEBUG")]
+ private void DebugUpdateRecording()
+ {
+ if (_watch != null)
+ {
+ ProcessTime = _watch.ElapsedMilliseconds;
+ }
+ }
+
+ [Conditional("DEBUG")]
+ private void DebugEndRecording()
+ {
+ if (_watch != null)
+ {
+ ProcessTime = _watch.ElapsedMilliseconds;
+ _watch = null;
+ }
+ }
+
+ private string SpawnTimeToString(float spawnTime)
+ {
+ float h = UnityEngine.Mathf.FloorToInt(spawnTime / 3600f);
+ float m = UnityEngine.Mathf.FloorToInt(spawnTime / 60f - h * 60f);
+ float s = UnityEngine.Mathf.FloorToInt(spawnTime - m * 60f - h * 3600f);
+ return h.ToString("00") + ":" + m.ToString("00") + ":" + s.ToString("00");
+ }
#endregion
#region 排序接口实现
diff --git a/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs
index 63433630..a8eaf78a 100644
--- a/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs
+++ b/Assets/YooAsset/Runtime/OperationSystem/OperationSystem.cs
@@ -132,5 +132,27 @@ namespace YooAsset
operation.SetPackageName(packageName);
operation.StartOperation();
}
+
+ #region 调试信息
+ internal static List GetDebugOperationInfos(string packageName)
+ {
+ List result = new List(_operations.Count);
+ foreach (var operation in _operations)
+ {
+ if (operation.PackageName == packageName)
+ {
+ var operationInfo = new DebugOperationInfo();
+ operationInfo.OperationName = operation.GetType().FullName;
+ operationInfo.Priority = operation.Priority;
+ operationInfo.Progress = operation.Progress;
+ operationInfo.BeginTime = operation.BeginTime;
+ operationInfo.ProcessTime = operation.ProcessTime;
+ operationInfo.Status = operation.Status.ToString();
+ result.Add(operationInfo);
+ }
+ }
+ return result;
+ }
+ #endregion
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs b/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs
index a239f46c..0fb91384 100644
--- a/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs
+++ b/Assets/YooAsset/Runtime/ResourceManager/Provider/ProviderOperation.cs
@@ -99,7 +99,6 @@ namespace YooAsset
}
internal override void InternalStart()
{
- DebugBeginRecording();
_steps = ESteps.StartBundleLoader;
}
internal override void InternalUpdate()
@@ -267,8 +266,6 @@ namespace YooAsset
///
protected void InvokeCompletion(string error, EOperationStatus status)
{
- DebugEndRecording();
-
_steps = ESteps.Done;
Error = error;
Status = status;
@@ -311,50 +308,10 @@ namespace YooAsset
///
public string SpawnScene = string.Empty;
- ///
- /// 出生的时间
- ///
- public string SpawnTime = string.Empty;
-
- ///
- /// 加载耗时(单位:毫秒)
- ///
- public long LoadingTime { protected set; get; }
-
- // 加载耗时统计
- private Stopwatch _watch = null;
-
[Conditional("DEBUG")]
- public void InitSpawnDebugInfo()
+ public void InitProviderDebugInfo()
{
- SpawnScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; ;
- SpawnTime = SpawnTimeToString(UnityEngine.Time.realtimeSinceStartup);
- }
- private string SpawnTimeToString(float spawnTime)
- {
- float h = UnityEngine.Mathf.FloorToInt(spawnTime / 3600f);
- float m = UnityEngine.Mathf.FloorToInt(spawnTime / 60f - h * 60f);
- float s = UnityEngine.Mathf.FloorToInt(spawnTime - m * 60f - h * 3600f);
- return h.ToString("00") + ":" + m.ToString("00") + ":" + s.ToString("00");
- }
-
- [Conditional("DEBUG")]
- private void DebugBeginRecording()
- {
- if (_watch == null)
- {
- _watch = Stopwatch.StartNew();
- }
- }
-
- [Conditional("DEBUG")]
- private void DebugEndRecording()
- {
- if (_watch != null)
- {
- LoadingTime = _watch.ElapsedMilliseconds;
- _watch = null;
- }
+ SpawnScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
}
///
diff --git a/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs b/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs
index 129b2e59..35869aa6 100644
--- a/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs
+++ b/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs
@@ -119,7 +119,7 @@ namespace YooAsset
ProviderOperation provider;
{
provider = new SceneProvider(this, providerGUID, assetInfo, loadSceneParams, suspendLoad);
- provider.InitSpawnDebugInfo();
+ provider.InitProviderDebugInfo();
ProviderDic.Add(providerGUID, provider);
OperationSystem.StartOperation(PackageName, provider);
}
@@ -158,7 +158,7 @@ namespace YooAsset
if (provider == null)
{
provider = new AssetProvider(this, providerGUID, assetInfo);
- provider.InitSpawnDebugInfo();
+ provider.InitProviderDebugInfo();
ProviderDic.Add(providerGUID, provider);
OperationSystem.StartOperation(PackageName, provider);
}
@@ -194,7 +194,7 @@ namespace YooAsset
if (provider == null)
{
provider = new SubAssetsProvider(this, providerGUID, assetInfo);
- provider.InitSpawnDebugInfo();
+ provider.InitProviderDebugInfo();
ProviderDic.Add(providerGUID, provider);
OperationSystem.StartOperation(PackageName, provider);
}
@@ -230,7 +230,7 @@ namespace YooAsset
if (provider == null)
{
provider = new AllAssetsProvider(this, providerGUID, assetInfo);
- provider.InitSpawnDebugInfo();
+ provider.InitProviderDebugInfo();
ProviderDic.Add(providerGUID, provider);
OperationSystem.StartOperation(PackageName, provider);
}
@@ -266,7 +266,7 @@ namespace YooAsset
if (provider == null)
{
provider = new RawFileProvider(this, providerGUID, assetInfo);
- provider.InitSpawnDebugInfo();
+ provider.InitProviderDebugInfo();
ProviderDic.Add(providerGUID, provider);
OperationSystem.StartOperation(PackageName, provider);
}
@@ -359,14 +359,6 @@ namespace YooAsset
}
#region 调试信息
- internal DebugPackageData GetDebugPackageData()
- {
- DebugPackageData data = new DebugPackageData();
- data.PackageName = PackageName;
- data.ProviderInfos = GetDebugProviderInfos();
- data.BundleInfos = GetDebugBundleInfos();
- return data;
- }
internal List GetDebugProviderInfos()
{
List result = new List(ProviderDic.Count);
@@ -375,8 +367,8 @@ namespace YooAsset
DebugProviderInfo providerInfo = new DebugProviderInfo();
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
providerInfo.SpawnScene = provider.SpawnScene;
- providerInfo.SpawnTime = provider.SpawnTime;
- providerInfo.LoadingTime = provider.LoadingTime;
+ providerInfo.BeginTime = provider.BeginTime;
+ providerInfo.LoadingTime = provider.ProcessTime;
providerInfo.RefCount = provider.RefCount;
providerInfo.Status = provider.Status.ToString();
providerInfo.DependBundles = provider.GetDebugDependBundles();
diff --git a/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs b/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs
index 69978b86..c5ed7b0a 100644
--- a/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs
+++ b/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs
@@ -1166,7 +1166,12 @@ namespace YooAsset
#region 调试信息
internal DebugPackageData GetDebugPackageData()
{
- return _resourceManager.GetDebugPackageData();
+ DebugPackageData data = new DebugPackageData();
+ data.PackageName = PackageName;
+ data.ProviderInfos = _resourceManager.GetDebugProviderInfos();
+ data.BundleInfos = _resourceManager.GetDebugBundleInfos();
+ data.OperationInfos = OperationSystem.GetDebugOperationInfos(PackageName);
+ return data;
}
#endregion
}