Repository navigation
Expand file tree
/
Copy pathUnityLogger.ts
More file actions
47 lines (38 loc) · 1.41 KB
/
Copy pathUnityLogger.ts
File metadata and controls
47 lines (38 loc) · 1.41 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
import { AssemblyHelper } from "../core/AssemblyHelper";
import { Constants } from "../data/Constants";
import { Logger } from "./Logger";
export class UnityLogger {
// Classes
private static Debug: Il2Cpp.Class;
// Methods
private static Log: Il2Cpp.Method;
private static LogWarning: Il2Cpp.Method;
private static LogError: Il2Cpp.Method;
static init(): void {
this.Debug = AssemblyHelper.CoreModule.class("UnityEngine.Debug");
this.Log = this.Debug.method<void>("Log", 1);
this.LogWarning = this.Debug.method("LogWarning", 1);
this.LogError = this.Debug.method("LogError", 1);
this.initHooks();
}
static initHooks(): void {
const module = this;
if (Constants.UNITY_LOGGING) {
//@ts-ignore
this.Log.implementation = function (object: Il2Cpp.Object): void {
Logger.unity("INFO", object);
module.Log.invoke(object);
};
//@ts-ignore
this.LogWarning.implementation = function (object: Il2Cpp.Object): void {
Logger.unity("WARN", object);
module.LogWarning.invoke(object);
};
//@ts-ignore
this.LogError.implementation = function (object: Il2Cpp.Object): void {
Logger.unity("ERROR", object);
module.LogError.invoke(object);
};
}
}
}