-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUnityDebugInterceptor.cs
More file actions
68 lines (63 loc) · 1.92 KB
/
UnityDebugInterceptor.cs
File metadata and controls
68 lines (63 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// ==============================
// UnityDebugInterceptor - Captures Unity Debug.Log calls
// ==============================
using System;
using GameSDK.ModHost;
using GameSDK.ModHost.Patching;
namespace MDB.Mods.UnityDebugInterceptor
{
/// <summary>
/// Mod that intercepts Unity's Debug.Log, Debug.LogWarning, and Debug.LogError
/// and redirects them to the MDB console with proper formatting.
/// </summary>
[Mod("MDB.UnityDebugInterceptor", "Unity Debug Interceptor", "1.0.0", Author = "MDB Team")]
public class UnityDebugInterceptorMod : ModBase
{
public override void OnLoad()
{
Logger.Info("Unity debug output will be captured");
}
}
/// <summary>
/// Patches Debug.Log to redirect to MDB console.
/// </summary>
[Patch("UnityEngine", "Debug")]
[PatchMethod("Log", 1)]
public static class DebugLogPatch
{
[Prefix]
public static bool Prefix(string __0)
{
ModLogger.LogInternal("Unity", __0 ?? "<null>", ConsoleColor.Gray);
return true; // Continue to original
}
}
/// <summary>
/// Patches Debug.LogWarning to redirect to MDB console.
/// </summary>
[Patch("UnityEngine", "Debug")]
[PatchMethod("LogWarning", 1)]
public static class DebugLogWarningPatch
{
[Prefix]
public static bool Prefix(string __0)
{
ModLogger.LogInternal("Unity.Warn", __0 ?? "<null>", ConsoleColor.Yellow);
return true;
}
}
/// <summary>
/// Patches Debug.LogError to redirect to MDB console.
/// </summary>
[Patch("UnityEngine", "Debug")]
[PatchMethod("LogError", 1)]
public static class DebugLogErrorPatch
{
[Prefix]
public static bool Prefix(string __0)
{
ModLogger.LogInternal("Unity.Error", __0 ?? "<null>", ConsoleColor.Red);
return true;
}
}
}