Compare commits

..

No commits in common. "ddda9e29dbed5dbe8e929f1d99f5cd8770727794" and "ed9692574c18d18c37392247293adefca65df761" have entirely different histories.

11 changed files with 79 additions and 163 deletions

View File

@ -59,10 +59,6 @@ namespace YooAsset.Editor
private string _searchKeyWord;
private DebugReport _currentReport;
private RemotePlayerSession _currentPlayerSession;
private double _lastRepaintTime = 0;
private int _nextRepaintIndex = -1;
private int _lastRepaintIndex = 0;
private int _rangeIndex = 0;
@ -165,20 +161,6 @@ namespace YooAsset.Editor
RemoteEditorConnection.Instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor);
_playerSessions.Clear();
}
public void Update()
{
// 每间隔0.5秒绘制一次页面
if (EditorApplication.timeSinceStartup - _lastRepaintTime > 0.5f)
{
_lastRepaintTime = EditorApplication.timeSinceStartup;
if (_nextRepaintIndex >= 0)
{
RepaintFrame(_nextRepaintIndex);
_lastRepaintIndex = _nextRepaintIndex;
_nextRepaintIndex = -1;
}
}
}
private void OnHandleConnectionEvent(int playerId)
{
@ -194,20 +176,19 @@ namespace YooAsset.Editor
{
var debugReport = DebugReport.Deserialize(args.data);
int playerId = args.playerId;
//Debug.Log($"Handle player {playerId} debug report !");
Debug.Log($"Handle player {playerId} debug report !");
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
_currentPlayerSession.AddDebugReport(debugReport);
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
UpdateRepaintIndex(_currentPlayerSession.MaxRangeValue);
UpdateFrameView(_currentPlayerSession);
}
private void OnFrameSliderChange(int sliderValue)
{
if (_currentPlayerSession != null)
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
UpdateRepaintIndex(_rangeIndex);
UpdateFrameView(_currentPlayerSession, _rangeIndex);
}
}
private void OnFrameLast_clicked()
@ -216,7 +197,7 @@ namespace YooAsset.Editor
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
_frameSlider.value = _rangeIndex;
UpdateRepaintIndex(_rangeIndex);
UpdateFrameView(_currentPlayerSession, _rangeIndex);
}
}
private void OnFrameNext_clicked()
@ -225,7 +206,7 @@ namespace YooAsset.Editor
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
_frameSlider.value = _rangeIndex;
UpdateRepaintIndex(_rangeIndex);
UpdateFrameView(_currentPlayerSession, _rangeIndex);
}
}
private void OnFrameClear_clicked()
@ -253,6 +234,42 @@ namespace YooAsset.Editor
RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
}
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
{
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
{
return session;
}
else
{
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
_playerSessions.Add(playerId, newSession);
return newSession;
}
}
private void UpdateFrameView(RemotePlayerSession playerSession)
{
if (playerSession != null)
{
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
}
}
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
{
if (playerSession == null)
return;
var debugReport = playerSession.GetDebugReport(rangeIndex);
if (debugReport != null)
{
_currentReport = debugReport;
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
_assetListViewer.FillViewData(debugReport);
_bundleListViewer.FillViewData(debugReport);
_operationListViewer.FillViewData(debugReport);
}
}
private void SampleBtn_onClick()
{
// 发送采集数据的命令
@ -330,9 +347,6 @@ namespace YooAsset.Editor
{
throw new NotImplementedException(viewMode.ToString());
}
// 重新绘制该帧数据
RepaintFrame(_lastRepaintIndex);
}
}
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
@ -343,56 +357,6 @@ namespace YooAsset.Editor
else
return DropdownMenuAction.Status.Normal;
}
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
{
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
{
return session;
}
else
{
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
_playerSessions.Add(playerId, newSession);
return newSession;
}
}
private void UpdateRepaintIndex(int rangeIndex)
{
_nextRepaintIndex = rangeIndex;
}
private void RepaintFrame(int repaintIndex)
{
var debugReport = _currentPlayerSession.GetDebugReport(repaintIndex);
if (debugReport != null)
{
_currentReport = debugReport;
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
if (_viewMode == EViewMode.AssetView)
{
_assetListViewer.FillViewData(debugReport);
_bundleListViewer.ClearView();
_operationListViewer.ClearView();
}
else if (_viewMode == EViewMode.BundleView)
{
_assetListViewer.ClearView();
_bundleListViewer.FillViewData(debugReport);
_operationListViewer.ClearView();
}
else if (_viewMode == EViewMode.OperationView)
{
_assetListViewer.ClearView();
_bundleListViewer.ClearView();
_operationListViewer.FillViewData(debugReport);
}
else
{
throw new System.NotImplementedException(_viewMode.ToString());
}
}
}
}
}
#endif

View File

@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace YooAsset.Editor
{
internal class RemotePlayerSession
{
private readonly Queue<DebugReport> _reports = new Queue<DebugReport>();
private readonly List<DebugReport> _reportList = new List<DebugReport>();
/// <summary>
/// 用户ID
@ -30,7 +29,7 @@ namespace YooAsset.Editor
{
get
{
int index = _reports.Count - 1;
int index = _reportList.Count - 1;
if (index < 0)
index = 0;
return index;
@ -38,7 +37,7 @@ namespace YooAsset.Editor
}
public RemotePlayerSession(int playerId, int maxReportCount = 500)
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
{
PlayerId = playerId;
MaxReportCount = maxReportCount;
@ -49,7 +48,7 @@ namespace YooAsset.Editor
/// </summary>
public void ClearDebugReport()
{
_reports.Clear();
_reportList.Clear();
}
/// <summary>
@ -60,9 +59,9 @@ namespace YooAsset.Editor
if (report == null)
Debug.LogWarning("Invalid debug report data !");
if (_reports.Count >= MaxReportCount)
_reports.Dequeue();
_reports.Enqueue(report);
if (_reportList.Count >= MaxReportCount)
_reportList.RemoveAt(0);
_reportList.Add(report);
}
/// <summary>
@ -70,11 +69,11 @@ namespace YooAsset.Editor
/// </summary>
public DebugReport GetDebugReport(int rangeIndex)
{
if (_reports.Count == 0)
if (_reportList.Count == 0)
return null;
if (rangeIndex < 0 || rangeIndex >= _reports.Count)
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
return null;
return _reports.ElementAt(rangeIndex);
return _reportList[rangeIndex];
}
/// <summary>

View File

@ -279,7 +279,7 @@ namespace YooAsset.Editor
{
StyleColor textColor;
var dependTableData = data as DependTableData;
if (dependTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
if (dependTableData.BundleInfo.Status == EOperationStatus.Failed)
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
@ -332,10 +332,8 @@ namespace YooAsset.Editor
public void ClearView()
{
_providerTableView.ClearAll(false, true);
_providerTableView.RebuildView();
_dependTableView.ClearAll(false, true);
_dependTableView.RebuildView();
RebuildView(null);
}
/// <summary>
@ -344,12 +342,10 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
if (_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
_providerTableView.RebuildView();
_dependTableView.RebuildView();
}
/// <summary>

View File

@ -151,7 +151,7 @@ namespace YooAsset.Editor
{
StyleColor textColor;
var bundleTableData = data as BundleTableData;
if (bundleTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
if (bundleTableData.BundleInfo.Status == EOperationStatus.Failed)
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
@ -341,7 +341,7 @@ namespace YooAsset.Editor
{
StyleColor textColor;
var feferenceTableData = data as ReferenceTableData;
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed)
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
@ -393,10 +393,8 @@ namespace YooAsset.Editor
{
_bundleTableView.ClearAll(false, true);
_bundleTableView.RebuildView();
_usingTableView.ClearAll(false, true);
_usingTableView.RebuildView();
_referenceTableView.ClearAll(false, true);
_referenceTableView.RebuildView();
}
@ -407,13 +405,10 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
if(_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
_bundleTableView.RebuildView();
_usingTableView.RebuildView();
_referenceTableView.RebuildView();
}
/// <summary>

View File

@ -337,10 +337,8 @@ namespace YooAsset.Editor
public void ClearView()
{
_operationTableView.ClearAll(false, true);
_operationTableView.RebuildView();
_childTreeView.ClearAll();
_childTreeView.RebuildView();
RebuildView(null);
}
/// <summary>
@ -349,7 +347,6 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
if(_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
@ -449,7 +446,7 @@ namespace YooAsset.Editor
}
private void BindTreeViewItem(VisualElement container, object userData)
{
var operationInfo = (DebugOperationInfo)userData;
var operationInfo = userData as DebugOperationInfo;
// OperationName
{

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset
{
[Serializable]
internal struct DebugBundleInfo : IComparer<DebugBundleInfo>, IComparable<DebugBundleInfo>
internal class DebugBundleInfo : IComparer<DebugBundleInfo>, IComparable<DebugBundleInfo>
{
/// <summary>
/// 资源包名称
@ -20,7 +20,7 @@ namespace YooAsset
/// <summary>
/// 加载状态
/// </summary>
public string Status;
public EOperationStatus Status;
/// <summary>
/// 谁引用了该资源包

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset
{
[Serializable]
internal struct DebugOperationInfo : IComparer<DebugOperationInfo>, IComparable<DebugOperationInfo>
internal class DebugOperationInfo : IComparer<DebugOperationInfo>, IComparable<DebugOperationInfo>
{
/// <summary>
/// 任务名称

View File

@ -47,7 +47,7 @@ namespace YooAsset
else
{
UnityEngine.Debug.LogError($"Can not found {nameof(DebugBundleInfo)} : {bundleName}");
return default;
return null;
}
}
}

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset
{
[Serializable]
internal struct DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
internal class DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
{
/// <summary>
/// 包裹名

View File

@ -385,7 +385,7 @@ namespace YooAsset
var bundleInfo = new DebugBundleInfo();
bundleInfo.BundleName = packageBundle.BundleName;
bundleInfo.RefCount = bundleLoader.RefCount;
bundleInfo.Status = bundleLoader.Status.ToString();
bundleInfo.Status = bundleLoader.Status;
bundleInfo.ReferenceBundles = FilterReferenceBundles(packageBundle);
result.Add(bundleInfo);
}

View File

@ -3,10 +3,10 @@ using UnityEngine;
namespace YooAsset
{
public static class YooAssetSettingsData
internal static class YooAssetSettingsData
{
private static YooAssetSettings _setting = null;
internal static YooAssetSettings Setting
public static YooAssetSettings Setting
{
get
{
@ -33,15 +33,6 @@ namespace YooAsset
}
}
/// <summary>
/// 获取YooAsset文件夹名称
/// </summary>
public static string GetDefaultYooFolderName()
{
return Setting.DefaultYooFolderName;
}
/// <summary>
/// 获取构建报告文件名
/// </summary>
@ -101,7 +92,7 @@ namespace YooAsset
/// <summary>
/// 获取YOO的Resources目录的加载路径
/// </summary>
internal static string GetYooResourcesLoadPath(string packageName, string fileName)
public static string GetYooResourcesLoadPath(string packageName, string fileName)
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return PathUtility.Combine(packageName, fileName);
@ -112,7 +103,7 @@ namespace YooAsset
/// <summary>
/// 获取YOO的Resources目录的全路径
/// </summary>
internal static string GetYooResourcesFullPath()
public static string GetYooResourcesFullPath()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return $"Assets/Resources";
@ -123,7 +114,7 @@ namespace YooAsset
/// <summary>
/// 获取YOO的编辑器下缓存文件根目录
/// </summary>
internal static string GetYooEditorCacheRoot()
public static string GetYooEditorCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
{
@ -141,9 +132,9 @@ namespace YooAsset
}
/// <summary>
/// 获取YOO的PC平台缓存文件根目录
/// 获取YOO的PC缓存文件根目录
/// </summary>
internal static string GetYooStandaloneWinCacheRoot()
public static string GetYooStandaloneCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.dataPath;
@ -152,31 +143,9 @@ namespace YooAsset
}
/// <summary>
/// 获取YOO的Linux平台缓存文件根目录
/// 获取YOO的移动端缓存文件根目录
/// </summary>
internal static string GetYooStandaloneLinuxCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.dataPath;
else
return PathUtility.Combine(Application.dataPath, Setting.DefaultYooFolderName);
}
/// <summary>
/// 获取YOO的Mac平台缓存文件根目录
/// </summary>
internal static string GetYooStandaloneMacCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.persistentDataPath;
else
return PathUtility.Combine(Application.persistentDataPath, Setting.DefaultYooFolderName);
}
/// <summary>
/// 获取YOO的移动平台缓存文件根目录
/// </summary>
internal static string GetYooMobileCacheRoot()
public static string GetYooMobileCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.persistentDataPath;
@ -187,16 +156,12 @@ namespace YooAsset
/// <summary>
/// 获取YOO默认的缓存文件根目录
/// </summary>
internal static string GetYooDefaultCacheRoot()
public static string GetYooDefaultCacheRoot()
{
#if UNITY_EDITOR
return GetYooEditorCacheRoot();
#elif UNITY_STANDALONE_WIN
return GetYooStandaloneWinCacheRoot();
#elif UNITY_STANDALONE_LINUX
return GetYooStandaloneLinuxCacheRoot();
#elif UNITY_STANDALONE_OSX
return GetYooStandaloneMacCacheRoot();
#elif UNITY_STANDALONE
return GetYooStandaloneCacheRoot();
#else
return GetYooMobileCacheRoot();
#endif
@ -205,7 +170,7 @@ namespace YooAsset
/// <summary>
/// 获取YOO默认的内置文件根目录
/// </summary>
internal static string GetYooDefaultBuildinRoot()
public static string GetYooDefaultBuildinRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.streamingAssetsPath;