mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-19 15:51:45 +00:00
v5: Fix log writer errors for Unity 6 (#1264)
This commit is contained in:
1 parent
3e8aebdb9b
commit
37f0a9aa5a
1 file changed
+17
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
@@ -30,6 +30,22 @@ namespace BepInEx.Logging
|
||||
break;
|
||||
}
|
||||
|
||||
// Fix for Unity 6. Both methods previously targeted no longer use internal calls
|
||||
if (WriteStringToUnityLog == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var type = Type.GetType("UnityEngine.UnityLogWriter, UnityEngine.CoreModule");
|
||||
var methodInfo = type.GetMethod("WriteStringToUnityLogImpl",
|
||||
BindingFlags.Static | BindingFlags.NonPublic,
|
||||
null,
|
||||
new Type[] { typeof(string) },
|
||||
null);
|
||||
methodInfo.Invoke(null, new object[] { "" });
|
||||
WriteStringToUnityLog = (Action<string>)Delegate.CreateDelegate(typeof(Action<string>), methodInfo);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
if (WriteStringToUnityLog == null)
|
||||
Logger.LogError("Unable to start Unity log writer");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user