File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
22using S1API . Logging ;
33using UnityEngine ;
4+ #if IL2CPPMELON
5+ using Il2CppInterop . Runtime ;
6+ #endif
47
58namespace S1API . Internal . Diagnostics
69{
@@ -11,6 +14,10 @@ internal static class UnityExceptionTraceHook
1114 {
1215 private static readonly Log Logger = new Log ( "UnityExceptionTrace" ) ;
1316 private static readonly object Sync = new object ( ) ;
17+ #if IL2CPPMELON
18+ private static readonly System . Action < string , string , LogType > ManagedCallback = OnUnityLogMessageReceived ;
19+ private static readonly Application . LogCallback Callback = DelegateSupport . ConvertDelegate < Application . LogCallback > ( ManagedCallback ) ;
20+ #endif
1421
1522 private static string _lastExceptionSignature ;
1623 private static DateTime _lastExceptionAtUtc ;
@@ -23,7 +30,11 @@ internal static void Install()
2330 return ;
2431 }
2532
33+ #if IL2CPPMELON
34+ Application . add_logMessageReceivedThreaded ( Callback ) ;
35+ #else
2636 Application . logMessageReceivedThreaded += OnUnityLogMessageReceived ;
37+ #endif
2738 _installed = true ;
2839 }
2940
@@ -34,8 +45,21 @@ internal static void Remove()
3445 return ;
3546 }
3647
37- Application . logMessageReceivedThreaded -= OnUnityLogMessageReceived ;
48+ #if IL2CPPMELON
3849 _installed = false ;
50+ return ;
51+ #else
52+ try
53+ {
54+ Application . logMessageReceivedThreaded -= OnUnityLogMessageReceived ;
55+ }
56+ catch ( Exception ex )
57+ {
58+ Logger . Warning ( $ "[Unity] Failed to remove threaded log callback during shutdown: { ex . Message } ") ;
59+ }
60+
61+ _installed = false ;
62+ #endif
3963 }
4064
4165 private static void OnUnityLogMessageReceived ( string condition , string stackTrace , LogType type )
You can’t perform that action at this time.
0 commit comments