From 3448ef75c241d34293c72d27be0c69466f652d08 Mon Sep 17 00:00:00 2001 From: mirfalltnixein Date: Thu, 5 Nov 2026 19:33:09 +0100 Subject: [PATCH] Log Unity stack traces on IL2CPP (#1424) UnityLogCallback ignored its second parameter, so Unity exceptions and errors logged only their message. Append the trace for Exception and Error when Unity gives one. The Mono source already does this for Exception. Log and Warning stay as they are, since in the game I tested Unity passed a trace for most of those. Fixes #660 Co-authored-by: mirfalltnixein <22786734+mirfalltnixein@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- .../Unity/BepInEx.Unity.IL2CPP/Logging/IL2CPPUnityLogSource.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Logging/IL2CPPUnityLogSource.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Logging/IL2CPPUnityLogSource.cs index 53e0d6b..8896e80 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Logging/IL2CPPUnityLogSource.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Logging/IL2CPPUnityLogSource.cs @@ -32,6 +32,9 @@ public class IL2CPPUnityLogSource : ILogSource LogType.Exception => LogLevel.Error, _ => LogLevel.Message }; + if (type is LogType.Exception or LogType.Error && !string.IsNullOrEmpty(exception)) + logLine += $"\nStack trace:\n{exception}"; + LogEvent?.Invoke(this, new LogEventArgs(logLine, level, this)); }