mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
[+] UI ErrorLog
[+] UI ErrorLog
This commit is contained in:
@@ -6,6 +6,7 @@ namespace TEngine.Editor.Inspector
|
||||
internal sealed class UIModuleInspector : GameFrameworkInspector
|
||||
{
|
||||
private SerializedProperty m_InstanceRoot = null;
|
||||
private SerializedProperty m_enableErrorLog = null;
|
||||
private SerializedProperty m_dontDestroyUIRoot = null;
|
||||
private SerializedProperty m_UICamera = null;
|
||||
|
||||
@@ -20,6 +21,7 @@ namespace TEngine.Editor.Inspector
|
||||
EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_InstanceRoot);
|
||||
EditorGUILayout.PropertyField(m_enableErrorLog);
|
||||
EditorGUILayout.PropertyField(m_dontDestroyUIRoot);
|
||||
EditorGUILayout.PropertyField(m_UICamera);
|
||||
}
|
||||
@@ -40,6 +42,7 @@ namespace TEngine.Editor.Inspector
|
||||
private void OnEnable()
|
||||
{
|
||||
m_InstanceRoot = serializedObject.FindProperty("m_InstanceRoot");
|
||||
m_enableErrorLog = serializedObject.FindProperty("m_enableErrorLog");
|
||||
m_dontDestroyUIRoot = serializedObject.FindProperty("m_dontDestroyUIRoot");
|
||||
m_UICamera = serializedObject.FindProperty("m_UICamera");
|
||||
|
||||
|
3
Assets/TEngine/Runtime/GameFramework/UI/ErrorLogger.meta
Normal file
3
Assets/TEngine/Runtime/GameFramework/UI/ErrorLogger.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fca85e737d54de0a3ed4bd7e7836fa4
|
||||
timeCreated: 1681807710
|
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
public class ErrorLogger
|
||||
{
|
||||
public ErrorLogger()
|
||||
{
|
||||
Application.logMessageReceived += LogHandler;
|
||||
}
|
||||
|
||||
~ErrorLogger()
|
||||
{
|
||||
Application.logMessageReceived -= LogHandler;
|
||||
}
|
||||
|
||||
private void LogHandler(string condition, string stacktrace, LogType type)
|
||||
{
|
||||
if (type == LogType.Exception)
|
||||
{
|
||||
string des = $"客户端报错, \n#内容#:---{condition} \n#位置#:---{stacktrace}";
|
||||
GameModule.UI.ShowUI<LogUI>(des);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ccc9fc5faf14d93baec285acaa97907
|
||||
timeCreated: 1681807720
|
35
Assets/TEngine/Runtime/GameFramework/UI/ErrorLogger/LogUI.cs
Normal file
35
Assets/TEngine/Runtime/GameFramework/UI/ErrorLogger/LogUI.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TEngine
|
||||
{
|
||||
[Window(UILayer.System)]
|
||||
class LogUI : UIWindow
|
||||
{
|
||||
#region 脚本工具生成的代码
|
||||
private Text m_textError;
|
||||
private Button m_btnClose;
|
||||
public override void ScriptGenerator()
|
||||
{
|
||||
m_textError = FindChildComponent<Text>("m_textError");
|
||||
m_btnClose = FindChildComponent<Button>("m_btnClose");
|
||||
m_btnClose.onClick.AddListener(UniTask.UnityAction(OnClickCloseBtn));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
private async UniTaskVoid OnClickCloseBtn()
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(0.5f));
|
||||
|
||||
Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override void OnRefresh()
|
||||
{
|
||||
m_textError.text = UserData.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faa647c543e54de9b2d55e189aef0eff
|
||||
timeCreated: 1681807986
|
@@ -18,6 +18,8 @@ namespace TEngine
|
||||
|
||||
[SerializeField] private bool m_dontDestroyUIRoot = true;
|
||||
|
||||
[SerializeField] private bool m_enableErrorLog = true;
|
||||
|
||||
[SerializeField] private Camera m_UICamera = null;
|
||||
|
||||
private readonly List<UIWindow> _stack = new List<UIWindow>(100);
|
||||
@@ -61,6 +63,11 @@ namespace TEngine
|
||||
|
||||
m_InstanceRoot.gameObject.layer = LayerMask.NameToLayer("UI");
|
||||
UIRootStatic = m_InstanceRoot;
|
||||
|
||||
if (m_enableErrorLog)
|
||||
{
|
||||
ErrorLogger errorLogger = new ErrorLogger();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
Reference in New Issue
Block a user