Update AssetBundleDebugger
parent
9cea3e1ba9
commit
d535500b9e
|
@ -43,6 +43,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
||||||
|
|
||||||
|
private Label _playerName;
|
||||||
private ToolbarMenu _viewModeMenu;
|
private ToolbarMenu _viewModeMenu;
|
||||||
private DebuggerAssetListViewer _assetListViewer;
|
private DebuggerAssetListViewer _assetListViewer;
|
||||||
private DebuggerBundleListViewer _bundleListViewer;
|
private DebuggerBundleListViewer _bundleListViewer;
|
||||||
|
@ -69,11 +70,15 @@ namespace YooAsset.Editor
|
||||||
var sampleBtn = root.Q<Button>("SampleButton");
|
var sampleBtn = root.Q<Button>("SampleButton");
|
||||||
sampleBtn.clicked += SampleBtn_onClick;
|
sampleBtn.clicked += SampleBtn_onClick;
|
||||||
|
|
||||||
|
// 用户列表菜单
|
||||||
|
_playerName = root.Q<Label>("PlayerName");
|
||||||
|
_playerName.text = "Editor player";
|
||||||
|
|
||||||
// 视口模式菜单
|
// 视口模式菜单
|
||||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||||
//_viewModeMenu.menu.AppendAction(EViewMode.MemoryView.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
|
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction, ViewModeMenuFun, EViewMode.AssetView);
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
|
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction, ViewModeMenuFun, EViewMode.BundleView);
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
|
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||||
|
|
||||||
// 搜索栏
|
// 搜索栏
|
||||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||||
|
@ -89,8 +94,14 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 显示视图
|
// 显示视图
|
||||||
_viewMode = EViewMode.AssetView;
|
_viewMode = EViewMode.AssetView;
|
||||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
|
||||||
_assetListViewer.AttachParent(root);
|
_assetListViewer.AttachParent(root);
|
||||||
|
|
||||||
|
// 远程调试
|
||||||
|
EditorConnection.instance.Initialize();
|
||||||
|
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||||
|
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||||
|
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||||
|
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -99,28 +110,22 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
}
|
// 远程调试
|
||||||
|
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
||||||
private void OnEnable()
|
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
||||||
{
|
|
||||||
EditorConnection.instance.Initialize();
|
|
||||||
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
|
||||||
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
|
||||||
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
|
||||||
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
|
||||||
}
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||||
_playerSessions.Clear();
|
_playerSessions.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnHandleConnectionEvent(int playerId)
|
private void OnHandleConnectionEvent(int playerId)
|
||||||
{
|
{
|
||||||
Debug.Log($"Game player connection : {playerId}");
|
Debug.Log($"Game player connection : {playerId}");
|
||||||
|
_playerName.text = $"Connected player : {playerId}";
|
||||||
}
|
}
|
||||||
private void OnHandleDisconnectionEvent(int playerId)
|
private void OnHandleDisconnectionEvent(int playerId)
|
||||||
{
|
{
|
||||||
Debug.Log($"Game player disconnection : {playerId}");
|
Debug.Log($"Game player disconnection : {playerId}");
|
||||||
|
_playerName.text = $"Disconneced player : {playerId}";
|
||||||
RemovePlayerSession(playerId);
|
RemovePlayerSession(playerId);
|
||||||
}
|
}
|
||||||
private void OnHandlePlayerMessage(MessageEventArgs args)
|
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||||
|
@ -175,38 +180,22 @@ namespace YooAsset.Editor
|
||||||
_bundleListViewer.FillViewData(_debugReport, _searchKeyWord);
|
_bundleListViewer.FillViewData(_debugReport, _searchKeyWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ViewModeMenuAction1(DropdownMenuAction action)
|
private void ViewModeMenuAction(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
if (_viewMode != EViewMode.AssetView)
|
var viewMode = (EViewMode)action.userData;
|
||||||
|
if (_viewMode != viewMode)
|
||||||
{
|
{
|
||||||
_viewMode = EViewMode.AssetView;
|
_viewMode = viewMode;
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
_viewModeMenu.text = viewMode.ToString();
|
||||||
_assetListViewer.AttachParent(root);
|
_assetListViewer.AttachParent(root);
|
||||||
_bundleListViewer.DetachParent();
|
_bundleListViewer.DetachParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ViewModeMenuAction2(DropdownMenuAction action)
|
private DropdownMenuAction.Status ViewModeMenuFun(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
if (_viewMode != EViewMode.BundleView)
|
var viewMode = (EViewMode)action.userData;
|
||||||
{
|
if (_viewMode == viewMode)
|
||||||
_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;
|
return DropdownMenuAction.Status.Checked;
|
||||||
else
|
else
|
||||||
return DropdownMenuAction.Status.Normal;
|
return DropdownMenuAction.Status.Normal;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||||
<uie:Toolbar name="Toolbar" style="display: flex;">
|
<uie:Toolbar name="Toolbar" style="display: flex;">
|
||||||
|
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: middle-left; padding-left: 5px;" />
|
||||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
||||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||||
|
|
|
@ -27,27 +27,16 @@ namespace YooAsset
|
||||||
#else
|
#else
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
PlayerConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
|
||||||
PlayerConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
|
||||||
PlayerConnection.instance.Register(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage);
|
PlayerConnection.instance.Register(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage);
|
||||||
}
|
}
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
PlayerConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage);
|
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)
|
private void OnHandleEditorMessage(MessageEventArgs args)
|
||||||
{
|
{
|
||||||
var command = RemoteCommand.Deserialize(args.data);
|
var command = RemoteCommand.Deserialize(args.data);
|
||||||
YooLogger.Log($"On handle remote command : {command.CommandType} : {command.CommandParam}");
|
YooLogger.Log($"On handle remote command : {command.CommandType} Param : {command.CommandParam}");
|
||||||
if (command.CommandType == (int)ERemoteCommand.SampleOnce)
|
if (command.CommandType == (int)ERemoteCommand.SampleOnce)
|
||||||
{
|
{
|
||||||
var debugReport = AssetSystem.GetDebugReport();
|
var debugReport = AssetSystem.GetDebugReport();
|
||||||
|
|
Loading…
Reference in New Issue