Open TheMineWay opened 3 months ago
using UnityEngine; public class GlobalExceptionHandler : MonoBehaviour { private void OnEnable() { Application.logMessageReceived += HandleLog; Application.logMessageReceivedThreaded += HandleLog; } private void OnDisable() { Application.logMessageReceived -= HandleLog; Application.logMessageReceivedThreaded -= HandleLog; } private void HandleLog(string logString, string stackTrace, LogType type) { if (type == LogType.Exception) { // Call your custom method here OnExceptionCaught(logString, stackTrace); } } private void OnExceptionCaught(string exceptionMessage, string stackTrace) { Debug.LogError("Exception Caught: " + exceptionMessage); Debug.LogError("Stack Trace: " + stackTrace); // Add custom logic to handle exceptions here } }