mirror of https://github.com/tuyoogame/YooAsset
parent
33387e8d26
commit
8deb239450
|
@ -1,144 +1,216 @@
|
||||||
#if UNITY_2019_4_OR_NEWER
|
#if UNITY_2019_4_OR_NEWER
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
using UnityEditor.UIElements;
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEditor.Networking.PlayerConnection;
|
||||||
|
using UnityEngine.Networking.PlayerConnection;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleDebuggerWindow : EditorWindow
|
public class AssetBundleDebuggerWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, EditorDefine.DockedWindowTypes);
|
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, EditorDefine.DockedWindowTypes);
|
||||||
wnd.minSize = new Vector2(800, 600);
|
wnd.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 视图模式
|
/// 视图模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private enum EViewMode
|
private enum EViewMode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内存视图
|
/// 内存视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
MemoryView,
|
MemoryView,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象视图
|
/// 资源对象视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AssetView,
|
AssetView,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包视图
|
/// 资源包视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BundleView,
|
BundleView,
|
||||||
}
|
}
|
||||||
|
|
||||||
private ToolbarMenu _viewModeMenu;
|
|
||||||
private DebuggerAssetListViewer _assetListViewer;
|
|
||||||
private DebuggerBundleListViewer _bundleListViewer;
|
|
||||||
|
|
||||||
private EViewMode _viewMode;
|
|
||||||
private readonly DebugReport _debugReport = new DebugReport();
|
|
||||||
private string _searchKeyWord;
|
|
||||||
|
|
||||||
|
|
||||||
public void CreateGUI()
|
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
||||||
{
|
|
||||||
|
private ToolbarMenu _viewModeMenu;
|
||||||
|
private DebuggerAssetListViewer _assetListViewer;
|
||||||
|
private DebuggerBundleListViewer _bundleListViewer;
|
||||||
|
|
||||||
|
private EViewMode _viewMode;
|
||||||
|
private DebugReport _debugReport;
|
||||||
|
private string _searchKeyWord;
|
||||||
|
|
||||||
|
|
||||||
|
public void CreateGUI()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
VisualElement root = rootVisualElement;
|
VisualElement root = rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
visualAsset.CloneTree(root);
|
|
||||||
|
|
||||||
// 采样按钮
|
visualAsset.CloneTree(root);
|
||||||
var sampleBtn = root.Q<Button>("SampleButton");
|
|
||||||
sampleBtn.clicked += SampleBtn_onClick;
|
|
||||||
|
|
||||||
// 视口模式菜单
|
// 采样按钮
|
||||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
var sampleBtn = root.Q<Button>("SampleButton");
|
||||||
//_viewModeMenu.menu.AppendAction(EViewMode.MemoryView.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
|
sampleBtn.clicked += SampleBtn_onClick;
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
|
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
|
|
||||||
|
|
||||||
// 搜索栏
|
// 视口模式菜单
|
||||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
//_viewModeMenu.menu.AppendAction(EViewMode.MemoryView.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
|
||||||
|
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
|
||||||
|
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
|
||||||
|
|
||||||
// 加载视图
|
// 搜索栏
|
||||||
_assetListViewer = new DebuggerAssetListViewer();
|
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||||
_assetListViewer.InitViewer();
|
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||||
|
|
||||||
// 加载视图
|
// 加载视图
|
||||||
_bundleListViewer = new DebuggerBundleListViewer();
|
_assetListViewer = new DebuggerAssetListViewer();
|
||||||
_bundleListViewer.InitViewer();
|
_assetListViewer.InitViewer();
|
||||||
|
|
||||||
// 显示视图
|
// 加载视图
|
||||||
_viewMode = EViewMode.AssetView;
|
_bundleListViewer = new DebuggerBundleListViewer();
|
||||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
_bundleListViewer.InitViewer();
|
||||||
_assetListViewer.AttachParent(root);
|
|
||||||
}
|
// 显示视图
|
||||||
catch(Exception e)
|
_viewMode = EViewMode.AssetView;
|
||||||
|
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||||
|
_assetListViewer.AttachParent(root);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogError(e.ToString());
|
Debug.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void SampleBtn_onClick()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
YooAssets.GetDebugReport(_debugReport);
|
}
|
||||||
_assetListViewer.FillViewData(_debugReport, _searchKeyWord);
|
|
||||||
_bundleListViewer.FillViewData(_debugReport, _searchKeyWord);
|
private void OnEnable()
|
||||||
}
|
{
|
||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
EditorConnection.instance.Initialize();
|
||||||
{
|
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||||
_searchKeyWord = e.newValue;
|
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||||
_assetListViewer.FillViewData(_debugReport, _searchKeyWord);
|
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||||
_bundleListViewer.FillViewData(_debugReport, _searchKeyWord);
|
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
||||||
}
|
}
|
||||||
private void ViewModeMenuAction1(DropdownMenuAction action)
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
if (_viewMode != EViewMode.AssetView)
|
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||||
{
|
_playerSessions.Clear();
|
||||||
_viewMode = EViewMode.AssetView;
|
}
|
||||||
VisualElement root = this.rootVisualElement;
|
private void OnHandleConnectionEvent(int playerId)
|
||||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
{
|
||||||
_assetListViewer.AttachParent(root);
|
Debug.Log($"Game player connection : {playerId}");
|
||||||
_bundleListViewer.DetachParent();
|
}
|
||||||
}
|
private void OnHandleDisconnectionEvent(int playerId)
|
||||||
}
|
{
|
||||||
private void ViewModeMenuAction2(DropdownMenuAction action)
|
Debug.Log($"Game player disconnection : {playerId}");
|
||||||
{
|
RemovePlayerSession(playerId);
|
||||||
if (_viewMode != EViewMode.BundleView)
|
}
|
||||||
{
|
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||||
_viewMode = EViewMode.BundleView;
|
{
|
||||||
VisualElement root = this.rootVisualElement;
|
var debugReport = DebugReport.Deserialize(args.data);
|
||||||
_viewModeMenu.text = EViewMode.BundleView.ToString();
|
OnHandleDebugReport(args.playerId, debugReport);
|
||||||
_assetListViewer.DetachParent();
|
}
|
||||||
_bundleListViewer.AttachParent(root);
|
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
||||||
}
|
{
|
||||||
}
|
var playerSession = GetOrCreatePlayerSession(playerId);
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
|
playerSession.AddDebugReport(debugReport);
|
||||||
{
|
|
||||||
if (_viewMode == EViewMode.AssetView)
|
_debugReport = debugReport;
|
||||||
return DropdownMenuAction.Status.Checked;
|
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||||
else
|
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||||
return DropdownMenuAction.Status.Normal;
|
}
|
||||||
}
|
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action)
|
{
|
||||||
{
|
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
||||||
if (_viewMode == EViewMode.BundleView)
|
{
|
||||||
return DropdownMenuAction.Status.Checked;
|
return session;
|
||||||
else
|
}
|
||||||
return DropdownMenuAction.Status.Normal;
|
else
|
||||||
}
|
{
|
||||||
}
|
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
||||||
|
_playerSessions.Add(playerId, newSession);
|
||||||
|
return newSession;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void RemovePlayerSession(int playerId)
|
||||||
|
{
|
||||||
|
if (_playerSessions.ContainsKey(playerId))
|
||||||
|
_playerSessions.Remove(playerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SampleBtn_onClick()
|
||||||
|
{
|
||||||
|
// 发送采集数据的命令
|
||||||
|
RemoteCommand command = new RemoteCommand();
|
||||||
|
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
||||||
|
command.CommandParam = string.Empty;
|
||||||
|
byte[] data = RemoteCommand.Serialize(command);
|
||||||
|
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
||||||
|
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
||||||
|
}
|
||||||
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
|
{
|
||||||
|
_searchKeyWord = e.newValue;
|
||||||
|
if (_debugReport != null)
|
||||||
|
{
|
||||||
|
_assetListViewer.FillViewData(_debugReport, _searchKeyWord);
|
||||||
|
_bundleListViewer.FillViewData(_debugReport, _searchKeyWord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ViewModeMenuAction1(DropdownMenuAction action)
|
||||||
|
{
|
||||||
|
if (_viewMode != EViewMode.AssetView)
|
||||||
|
{
|
||||||
|
_viewMode = EViewMode.AssetView;
|
||||||
|
VisualElement root = this.rootVisualElement;
|
||||||
|
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||||
|
_assetListViewer.AttachParent(root);
|
||||||
|
_bundleListViewer.DetachParent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ViewModeMenuAction2(DropdownMenuAction action)
|
||||||
|
{
|
||||||
|
if (_viewMode != EViewMode.BundleView)
|
||||||
|
{
|
||||||
|
_viewMode = EViewMode.BundleView;
|
||||||
|
VisualElement root = this.rootVisualElement;
|
||||||
|
_viewModeMenu.text = EViewMode.BundleView.ToString();
|
||||||
|
_assetListViewer.DetachParent();
|
||||||
|
_bundleListViewer.AttachParent(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
|
||||||
|
{
|
||||||
|
if (_viewMode == EViewMode.AssetView)
|
||||||
|
return DropdownMenuAction.Status.Checked;
|
||||||
|
else
|
||||||
|
return DropdownMenuAction.Status.Normal;
|
||||||
|
}
|
||||||
|
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action)
|
||||||
|
{
|
||||||
|
if (_viewMode == EViewMode.BundleView)
|
||||||
|
return DropdownMenuAction.Status.Checked;
|
||||||
|
else
|
||||||
|
return DropdownMenuAction.Status.Normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
internal class RemotePlayerSession
|
||||||
|
{
|
||||||
|
private readonly List<DebugReport> _reportList = new List<DebugReport>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户ID
|
||||||
|
/// </summary>
|
||||||
|
public int PlayerId { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存的报告最大数量
|
||||||
|
/// </summary>
|
||||||
|
public int MaxReportCount { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
||||||
|
{
|
||||||
|
PlayerId = playerId;
|
||||||
|
MaxReportCount = maxReportCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加一个调试报告
|
||||||
|
/// </summary>
|
||||||
|
public void AddDebugReport(DebugReport report)
|
||||||
|
{
|
||||||
|
if (report == null)
|
||||||
|
Debug.LogWarning("Invalid debug report data !");
|
||||||
|
|
||||||
|
if (_reportList.Count >= MaxReportCount)
|
||||||
|
_reportList.RemoveAt(0);
|
||||||
|
_reportList.Add(report);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取最近一次的报告
|
||||||
|
/// </summary>
|
||||||
|
public DebugReport GetLatestReport()
|
||||||
|
{
|
||||||
|
if (_reportList.Count == 0)
|
||||||
|
return null;
|
||||||
|
return _reportList[_reportList.Count - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 89b4ea90b9f7e474d9e80077656ef6c4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -171,7 +171,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
if (providerInfo.Status == ProviderBase.EStatus.Fail)
|
if (providerInfo.Status == (int)ProviderBase.EStatus.Fail)
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = label1.style.color;
|
textColor = label1.style.color;
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
if (bundleInfo.Status == AssetBundleLoaderBase.EStatus.Failed)
|
if (bundleInfo.Status == (int)AssetBundleLoaderBase.EStatus.Failed)
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = label1.style.color;
|
textColor = label1.style.color;
|
||||||
|
|
|
@ -321,9 +321,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 调试专属方法
|
#region 调试专属方法
|
||||||
internal static void GetDebugReport(DebugReport report)
|
internal static DebugReport GetDebugReport()
|
||||||
{
|
{
|
||||||
report.ClearAll();
|
DebugReport report = new DebugReport();
|
||||||
|
report.FrameCount = Time.frameCount;
|
||||||
report.BundleCount = _loaders.Count;
|
report.BundleCount = _loaders.Count;
|
||||||
report.AssetCount = _providers.Count;
|
report.AssetCount = _providers.Count;
|
||||||
|
|
||||||
|
@ -334,8 +335,8 @@ namespace YooAsset
|
||||||
providerInfo.SpawnScene = provider.SpawnScene;
|
providerInfo.SpawnScene = provider.SpawnScene;
|
||||||
providerInfo.SpawnTime = provider.SpawnTime;
|
providerInfo.SpawnTime = provider.SpawnTime;
|
||||||
providerInfo.RefCount = provider.RefCount;
|
providerInfo.RefCount = provider.RefCount;
|
||||||
providerInfo.Status = provider.Status;
|
providerInfo.Status = (int)provider.Status;
|
||||||
providerInfo.BundleInfos.Clear();
|
providerInfo.BundleInfos = new List<DebugBundleInfo>();
|
||||||
report.ProviderInfos.Add(providerInfo);
|
report.ProviderInfos.Add(providerInfo);
|
||||||
|
|
||||||
if (provider is BundledProvider)
|
if (provider is BundledProvider)
|
||||||
|
@ -347,6 +348,7 @@ namespace YooAsset
|
||||||
|
|
||||||
// 重新排序
|
// 重新排序
|
||||||
report.ProviderInfos.Sort();
|
report.ProviderInfos.Sort();
|
||||||
|
return report;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ namespace YooAsset
|
||||||
if (_isShowWaitForAsyncError == false)
|
if (_isShowWaitForAsyncError == false)
|
||||||
{
|
{
|
||||||
_isShowWaitForAsyncError = true;
|
_isShowWaitForAsyncError = true;
|
||||||
YooLogger.Error($"WaitForAsyncComplete failed ! BundleName : {MainBundleInfo.BundleName} States : {Status}");
|
YooLogger.Error($"WaitForAsyncComplete failed ! Try load bundle : {MainBundleInfo.BundleName} from remote with sync load method !");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace YooAsset
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private float _tryTimer = 0;
|
private float _tryTimer = 0;
|
||||||
private string _webURL;
|
private string _webURL;
|
||||||
|
private bool _isShowWaitForAsyncError = false;
|
||||||
private UnityWebRequest _webRequest;
|
private UnityWebRequest _webRequest;
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,7 +119,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void WaitForAsyncComplete()
|
public override void WaitForAsyncComplete()
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException($"WebGL platform not support {nameof(WaitForAsyncComplete)}");
|
if (_isShowWaitForAsyncError == false)
|
||||||
|
{
|
||||||
|
_isShowWaitForAsyncError = true;
|
||||||
|
YooLogger.Error($"WebGL platform not support {nameof(WaitForAsyncComplete)} ! Use the async load method instead of the sync load method !");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -104,7 +104,7 @@ namespace YooAsset
|
||||||
var bundleInfo = new DebugBundleInfo();
|
var bundleInfo = new DebugBundleInfo();
|
||||||
bundleInfo.BundleName = loader.MainBundleInfo.BundleName;
|
bundleInfo.BundleName = loader.MainBundleInfo.BundleName;
|
||||||
bundleInfo.RefCount = loader.RefCount;
|
bundleInfo.RefCount = loader.RefCount;
|
||||||
bundleInfo.Status = loader.Status;
|
bundleInfo.Status = (int)loader.Status;
|
||||||
output.Add(bundleInfo);
|
output.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace YooAsset
|
||||||
var bundleInfo = new DebugBundleInfo();
|
var bundleInfo = new DebugBundleInfo();
|
||||||
bundleInfo.BundleName = OwnerBundle.MainBundleInfo.BundleName;
|
bundleInfo.BundleName = OwnerBundle.MainBundleInfo.BundleName;
|
||||||
bundleInfo.RefCount = OwnerBundle.RefCount;
|
bundleInfo.RefCount = OwnerBundle.RefCount;
|
||||||
bundleInfo.Status = OwnerBundle.Status;
|
bundleInfo.Status = (int)OwnerBundle.Status;
|
||||||
output.Add(bundleInfo);
|
output.Add(bundleInfo);
|
||||||
|
|
||||||
DependBundleGroup.GetBundleDebugInfos(output);
|
DependBundleGroup.GetBundleDebugInfos(output);
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
internal class DebugBundleInfo
|
internal class DebugBundleInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BundleName { set; get; }
|
public string BundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引用计数
|
/// 引用计数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int RefCount { set; get; }
|
public int RefCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载状态
|
/// 加载状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AssetBundleLoaderBase.EStatus Status { set; get; }
|
public int Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,37 +4,38 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
internal class DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
|
internal class DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象路径
|
/// 资源对象路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { set; get; }
|
public string AssetPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源出生的场景
|
/// 资源出生的场景
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SpawnScene { set; get; }
|
public string SpawnScene;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源出生的时间
|
/// 资源出生的时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SpawnTime { set; get; }
|
public string SpawnTime;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引用计数
|
/// 引用计数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int RefCount { set; get; }
|
public int RefCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载状态
|
/// 加载状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProviderBase.EStatus Status { set; get; }
|
public int Status;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源包列表
|
/// 依赖的资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<DebugBundleInfo> BundleInfos = new List<DebugBundleInfo>();
|
public List<DebugBundleInfo> BundleInfos;
|
||||||
|
|
||||||
public int CompareTo(DebugProviderInfo other)
|
public int CompareTo(DebugProviderInfo other)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,21 +1,49 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源系统调试信息
|
/// 资源系统调试信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
internal class DebugReport
|
internal class DebugReport
|
||||||
{
|
{
|
||||||
public readonly List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
|
public List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
|
||||||
public int BundleCount { set; get; }
|
|
||||||
public int AssetCount { set; get; }
|
|
||||||
|
|
||||||
public void ClearAll()
|
/// <summary>
|
||||||
{
|
/// 游戏帧
|
||||||
ProviderInfos.Clear();
|
/// </summary>
|
||||||
}
|
public int FrameCount;
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包总数
|
||||||
|
/// </summary>
|
||||||
|
public int BundleCount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源对象总数
|
||||||
|
/// </summary>
|
||||||
|
public int AssetCount;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 序列化
|
||||||
|
/// </summary>
|
||||||
|
public static byte[] Serialize(DebugReport debugReport)
|
||||||
|
{
|
||||||
|
return Encoding.UTF8.GetBytes(JsonUtility.ToJson(debugReport));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反序列化
|
||||||
|
/// </summary>
|
||||||
|
public static DebugReport Deserialize(byte[] data)
|
||||||
|
{
|
||||||
|
return JsonUtility.FromJson<DebugReport>(Encoding.UTF8.GetString(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal enum ERemoteCommand
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 采样一次
|
||||||
|
/// </summary>
|
||||||
|
SampleOnce = 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
internal class RemoteCommand
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 命令类型
|
||||||
|
/// </summary>
|
||||||
|
public int CommandType;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 命令附加参数
|
||||||
|
/// </summary>
|
||||||
|
public string CommandParam;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 序列化
|
||||||
|
/// </summary>
|
||||||
|
public static byte[] Serialize(RemoteCommand command)
|
||||||
|
{
|
||||||
|
return Encoding.UTF8.GetBytes(JsonUtility.ToJson(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反序列化
|
||||||
|
/// </summary>
|
||||||
|
public static RemoteCommand Deserialize(byte[] data)
|
||||||
|
{
|
||||||
|
return JsonUtility.FromJson<RemoteCommand>(Encoding.UTF8.GetString(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e79402f4d610fb4408aa6f8a94b09cb9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class RemoteDebuggerDefine
|
||||||
|
{
|
||||||
|
public static readonly Guid kMsgSendPlayerToEditor = new Guid("e34a5702dd353724aa315fb8011f08c3");
|
||||||
|
public static readonly Guid kMsgSendEditorToPlayer = new Guid("4d1926c9df5b052469a1c63448b7609a");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3fd4f5f47edbfd54ba92427daf9ea3a4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,64 @@
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking.PlayerConnection;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class RemoteDebuggerInRuntime : MonoBehaviour
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下获取报告的回调
|
||||||
|
/// </summary>
|
||||||
|
public static Action<int, DebugReport> EditorHandleDebugReportCallback;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下请求报告数据
|
||||||
|
/// </summary>
|
||||||
|
public static void EditorRequestDebugReport()
|
||||||
|
{
|
||||||
|
if(UnityEditor.EditorApplication.isPlaying)
|
||||||
|
{
|
||||||
|
var report = AssetSystem.GetDebugReport();
|
||||||
|
EditorHandleDebugReportCallback?.Invoke(0, report);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
PlayerConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||||
|
PlayerConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||||
|
PlayerConnection.instance.Register(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage);
|
||||||
|
}
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
PlayerConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnHandleConnectionEvent(int id)
|
||||||
|
{
|
||||||
|
YooLogger.Log($"Editor player connection : {id}");
|
||||||
|
}
|
||||||
|
private void OnHandleDisconnectionEvent(int id)
|
||||||
|
{
|
||||||
|
YooLogger.Log($"Editor player disconnection : {id}");
|
||||||
|
}
|
||||||
|
private void OnHandleEditorMessage(MessageEventArgs args)
|
||||||
|
{
|
||||||
|
var command = RemoteCommand.Deserialize(args.data);
|
||||||
|
YooLogger.Log($"On handle remote command : {command.CommandType} : {command.CommandParam}");
|
||||||
|
if (command.CommandType == (int)ERemoteCommand.SampleOnce)
|
||||||
|
{
|
||||||
|
var debugReport = AssetSystem.GetDebugReport();
|
||||||
|
var data = DebugReport.Serialize(debugReport);
|
||||||
|
PlayerConnection.instance.Send(RemoteDebuggerDefine.kMsgSendPlayerToEditor, data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException(command.CommandType.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 91030c545c99c944a846f6a9a2a0756a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -117,7 +117,6 @@ namespace YooAsset
|
||||||
private static OfflinePlayModeImpl _offlinePlayModeImpl;
|
private static OfflinePlayModeImpl _offlinePlayModeImpl;
|
||||||
private static HostPlayModeImpl _hostPlayModeImpl;
|
private static HostPlayModeImpl _hostPlayModeImpl;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -143,6 +142,10 @@ namespace YooAsset
|
||||||
UnityEngine.GameObject driverGo = new UnityEngine.GameObject("[YooAsset]");
|
UnityEngine.GameObject driverGo = new UnityEngine.GameObject("[YooAsset]");
|
||||||
driverGo.AddComponent<YooAssetDriver>();
|
driverGo.AddComponent<YooAssetDriver>();
|
||||||
UnityEngine.Object.DontDestroyOnLoad(driverGo);
|
UnityEngine.Object.DontDestroyOnLoad(driverGo);
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
driverGo.AddComponent<RemoteDebuggerInRuntime>();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -934,17 +937,6 @@ namespace YooAsset
|
||||||
AssetSystem.Update();
|
AssetSystem.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取调试信息
|
|
||||||
/// </summary>
|
|
||||||
internal static void GetDebugReport(DebugReport report)
|
|
||||||
{
|
|
||||||
if (report == null)
|
|
||||||
YooLogger.Error($"{nameof(DebugReport)} is null");
|
|
||||||
|
|
||||||
AssetSystem.GetDebugReport(report);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位地址转换为资源完整路径
|
/// 资源定位地址转换为资源完整路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue