2
2
using System ;
3
3
using System . Collections . Generic ;
4
4
using System . Linq ;
5
+ using System . Reflection ;
6
+ using BF = System . Reflection . BindingFlags ;
5
7
using System . Text ;
6
8
using UnhollowerBaseLib ;
7
9
using UnhollowerRuntimeLib ;
@@ -21,14 +23,22 @@ public override void Initialize()
21
23
22
24
public override void SetupEvents ( )
23
25
{
24
- Application . add_logMessageReceived (
25
- new Action < string , string , LogType > ( ExplorerCore . Instance . OnUnityLog ) ) ;
26
-
27
- //SceneManager.add_sceneLoaded(
28
- // new Action<Scene, LoadSceneMode>(ExplorerCore.Instance.OnSceneLoaded1));
29
-
30
- //SceneManager.add_activeSceneChanged(
31
- // new Action<Scene, Scene>(ExplorerCore.Instance.OnSceneLoaded2));
26
+ try
27
+ {
28
+ //Application.add_logMessageReceived(new Action<string, string, LogType>(ExplorerCore.Instance.OnUnityLog));
29
+
30
+ var logType = ReflectionUtility . GetTypeByName ( "UnityEngine.Application+LogCallback" ) ;
31
+ var castMethod = logType . GetMethod ( "op_Implicit" , new [ ] { typeof ( Action < string , string , LogType > ) } ) ;
32
+ var addMethod = typeof ( Application ) . GetMethod ( "add_logMessageReceived" , BF . Static | BF . Public , null , new [ ] { logType } , null ) ;
33
+ addMethod . Invoke ( null , new [ ]
34
+ {
35
+ castMethod . Invoke ( null , new [ ] { new Action < string , string , LogType > ( ExplorerCore . Instance . OnUnityLog ) } )
36
+ } ) ;
37
+ }
38
+ catch
39
+ {
40
+ ExplorerCore . LogWarning ( "Exception setting up Unity log listener, make sure Unity libraries have been unstripped!" ) ;
41
+ }
32
42
}
33
43
34
44
internal delegate IntPtr d_LayerToName ( int layer ) ;
0 commit comments