2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
4
using System . Linq ;
5
- using System . Text ;
6
5
using UnityEngine ;
7
6
using MelonLoader ;
8
- using UnhollowerBaseLib ;
9
- using UnhollowerRuntimeLib ;
10
- using Harmony ;
11
- using Il2CppSystem . Runtime . InteropServices ;
12
7
13
8
namespace Explorer
14
9
{
@@ -17,53 +12,23 @@ public class CppExplorer : MelonMod
17
12
// consts
18
13
19
14
public const string ID = "com.sinai.cppexplorer" ;
20
- public const string VERSION = "1.3.3 " ;
15
+ public const string VERSION = "1.3.5 " ;
21
16
public const string AUTHOR = "Sinai" ;
22
17
18
+ public const string NAME = "IL2CPP Runtime Explorer"
23
19
#if Release_Unity2018
24
- public const string NAME = "IL2CPP Runtime Explorer (Unity 2018)" ;
25
- #else
26
- public const string NAME = "IL2CPP Runtime Explorer" ;
20
+ + " (Unity 2018)"
27
21
#endif
22
+ ;
28
23
29
24
// fields
30
25
31
26
public static CppExplorer Instance ;
32
- private string m_objUnderMouseName = "" ;
33
- private Camera m_main ;
34
27
35
28
// props
36
29
37
30
public static bool ShowMenu { get ; set ; } = false ;
38
31
public static int ArrayLimit { get ; set ; } = 20 ;
39
- public bool MouseInspect { get ; set ; } = false ;
40
-
41
- // prop helpers
42
-
43
- public static Il2CppSystem . Type GameObjectType => Il2CppType . Of < GameObject > ( ) ;
44
- public static Il2CppSystem . Type TransformType => Il2CppType . Of < Transform > ( ) ;
45
- public static Il2CppSystem . Type ObjectType => Il2CppType . Of < UnityEngine . Object > ( ) ;
46
- public static Il2CppSystem . Type ComponentType => Il2CppType . Of < Component > ( ) ;
47
-
48
- public static string ActiveSceneName
49
- {
50
- get
51
- {
52
- return UnityEngine . SceneManagement . SceneManager . GetActiveScene ( ) . name ;
53
- }
54
- }
55
-
56
- public Camera MainCamera
57
- {
58
- get
59
- {
60
- if ( m_main == null )
61
- {
62
- m_main = Camera . main ;
63
- }
64
- return m_main ;
65
- }
66
- }
67
32
68
33
// methods
69
34
@@ -76,21 +41,15 @@ public override void OnApplicationStart()
76
41
new MainMenu ( ) ;
77
42
new WindowManager ( ) ;
78
43
79
- // done init
80
44
ShowMenu = true ;
81
45
}
82
46
83
- // On scene change
84
47
public override void OnLevelWasLoaded ( int level )
85
48
{
86
- if ( ScenePage . Instance != null )
87
- {
88
- ScenePage . Instance . OnSceneChange ( ) ;
89
- SearchPage . Instance . OnSceneChange ( ) ;
90
- }
49
+ ScenePage . Instance ? . OnSceneChange ( ) ;
50
+ SearchPage . Instance ? . OnSceneChange ( ) ;
91
51
}
92
52
93
- // Update
94
53
public override void OnUpdate ( )
95
54
{
96
55
if ( Input . GetKeyDown ( KeyCode . F7 ) )
@@ -109,43 +68,7 @@ public override void OnUpdate()
109
68
MainMenu . Instance . Update ( ) ;
110
69
WindowManager . Instance . Update ( ) ;
111
70
112
- if ( Input . GetKey ( KeyCode . LeftShift ) && Input . GetMouseButtonDown ( 1 ) )
113
- {
114
- MouseInspect = ! MouseInspect ;
115
- }
116
-
117
- if ( MouseInspect )
118
- {
119
- InspectUnderMouse ( ) ;
120
- }
121
- }
122
- else if ( MouseInspect )
123
- {
124
- MouseInspect = false ;
125
- }
126
- }
127
-
128
- private void InspectUnderMouse ( )
129
- {
130
- Ray ray = MainCamera . ScreenPointToRay ( Input . mousePosition ) ;
131
-
132
- if ( Physics . Raycast ( ray , out RaycastHit hit , 1000f ) )
133
- {
134
- var obj = hit . transform . gameObject ;
135
-
136
- m_objUnderMouseName = GetGameObjectPath ( obj . transform ) ;
137
-
138
- if ( Input . GetMouseButtonDown ( 0 ) )
139
- {
140
- MouseInspect = false ;
141
- m_objUnderMouseName = "" ;
142
-
143
- WindowManager . InspectObject ( obj , out _ ) ;
144
- }
145
- }
146
- else
147
- {
148
- m_objUnderMouseName = "" ;
71
+ InspectUnderMouse . Update ( ) ;
149
72
}
150
73
}
151
74
@@ -156,79 +79,7 @@ public override void OnGUI()
156
79
MainMenu . Instance . OnGUI ( ) ;
157
80
WindowManager . Instance . OnGUI ( ) ;
158
81
159
- if ( MouseInspect )
160
- {
161
- if ( m_objUnderMouseName != "" )
162
- {
163
- var pos = Input . mousePosition ;
164
- var rect = new Rect (
165
- pos . x - ( Screen . width / 2 ) , // x
166
- Screen . height - pos . y - 50 , // y
167
- Screen . width , // w
168
- 50 // h
169
- ) ;
170
-
171
- var origAlign = GUI . skin . label . alignment ;
172
- GUI . skin . label . alignment = TextAnchor . MiddleCenter ;
173
-
174
- //shadow text
175
- GUI . Label ( rect , $ "<color=black>{ m_objUnderMouseName } </color>") ;
176
- //white text
177
- GUI . Label ( new Rect ( rect . x - 1 , rect . y + 1 , rect . width , rect . height ) , m_objUnderMouseName ) ;
178
-
179
- GUI . skin . label . alignment = origAlign ;
180
- }
181
- }
182
- }
183
-
184
- // ************** public helpers **************
185
-
186
- public static object Il2CppCast ( object obj , Type castTo )
187
- {
188
- var method = typeof ( Il2CppObjectBase ) . GetMethod ( "TryCast" ) ;
189
- var generic = method . MakeGenericMethod ( castTo ) ;
190
- return generic . Invoke ( obj , null ) ;
191
- }
192
-
193
- public static string GetGameObjectPath ( Transform _transform )
194
- {
195
- return GetGameObjectPath ( _transform , true ) ;
196
- }
197
-
198
- public static string GetGameObjectPath ( Transform _transform , bool _includeItemName )
199
- {
200
- string text = _includeItemName ? ( "/" + _transform . name ) : "" ;
201
- GameObject gameObject = _transform . gameObject ;
202
- while ( gameObject . transform . parent != null )
203
- {
204
- gameObject = gameObject . transform . parent . gameObject ;
205
- text = "/" + gameObject . name + text ;
206
- }
207
- return text ;
208
- }
209
-
210
- public static Type GetType ( string _type )
211
- {
212
- try
213
- {
214
- foreach ( var asm in AppDomain . CurrentDomain . GetAssemblies ( ) )
215
- {
216
- try
217
- {
218
- if ( asm . GetType ( _type ) is Type type )
219
- {
220
- return type ;
221
- }
222
- }
223
- catch { }
224
- }
225
-
226
- return null ;
227
- }
228
- catch
229
- {
230
- return null ;
231
- }
82
+ InspectUnderMouse . OnGUI ( ) ;
232
83
}
233
84
}
234
85
}
0 commit comments