更新Demo

更新Demo
This commit is contained in:
ALEXTANG
2023-12-20 12:14:27 +08:00
parent f64bb37706
commit 17a5d7425c
847 changed files with 106095 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
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 = YooAssets.GetDebugReport();
EditorHandleDebugReportCallback?.Invoke(0, report);
}
}
#else
private void OnEnable()
{
PlayerConnection.instance.Register(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage);
}
private void OnDisable()
{
PlayerConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage);
}
private void OnHandleEditorMessage(MessageEventArgs args)
{
var command = RemoteCommand.Deserialize(args.data);
YooLogger.Log($"On handle remote command : {command.CommandType} Param : {command.CommandParam}");
if (command.CommandType == (int)ERemoteCommand.SampleOnce)
{
var debugReport = YooAssets.GetDebugReport();
var data = DebugReport.Serialize(debugReport);
PlayerConnection.instance.Send(RemoteDebuggerDefine.kMsgSendPlayerToEditor, data);
}
else
{
throw new NotImplementedException(command.CommandType.ToString());
}
}
#endif
}
}