42 lines
928 B
C#
42 lines
928 B
C#
using UnityEngine;
|
|
|
|
public class ErrorLogHookManager : MonoBehaviour
|
|
{
|
|
[RuntimeInitializeOnLoadMethod]
|
|
static void OnRuntimeMethodLoad()
|
|
{
|
|
new GameObject("ErrorLogHookManager").AddComponent<ErrorLogHookManager>();
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
Application.logMessageReceived += HandleLog;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
Application.logMessageReceived -= HandleLog;
|
|
}
|
|
|
|
void HandleLog(string logString, string stackTrace, LogType type)
|
|
{
|
|
#if !FGB_LIVE
|
|
switch (type)
|
|
{
|
|
#if !UNITY_EDITOR
|
|
default: Debug.Log(logString); break;
|
|
#endif
|
|
case LogType.Error:
|
|
case LogType.Exception:
|
|
//Debug.LogError(logString);
|
|
break;
|
|
}
|
|
MyTestUI.Add_Log(type, $"{logString}\n\n{stackTrace}");
|
|
#endif
|
|
}
|
|
} |