22using System . Collections ;
33using System . Collections . Generic ;
44using System . Linq ;
5- using System . Text ;
65using UnityEngine ;
76using MelonLoader ;
8- using UnhollowerBaseLib ;
9- using UnhollowerRuntimeLib ;
10- using Harmony ;
11- using Il2CppSystem . Runtime . InteropServices ;
127
138namespace Explorer
149{
@@ -17,53 +12,23 @@ public class CppExplorer : MelonMod
1712 // consts
1813
1914 public const string ID = "com.sinai.cppexplorer" ;
20- public const string VERSION = "1.3.3 " ;
15+ public const string VERSION = "1.3.5 " ;
2116 public const string AUTHOR = "Sinai" ;
2217
18+ public const string NAME = "IL2CPP Runtime Explorer"
2319#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)"
2721#endif
22+ ;
2823
2924 // fields
3025
3126 public static CppExplorer Instance ;
32- private string m_objUnderMouseName = "" ;
33- private Camera m_main ;
3427
3528 // props
3629
3730 public static bool ShowMenu { get ; set ; } = false ;
3831 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- }
6732
6833 // methods
6934
@@ -76,21 +41,15 @@ public override void OnApplicationStart()
7641 new MainMenu ( ) ;
7742 new WindowManager ( ) ;
7843
79- // done init
8044 ShowMenu = true ;
8145 }
8246
83- // On scene change
8447 public override void OnLevelWasLoaded ( int level )
8548 {
86- if ( ScenePage . Instance != null )
87- {
88- ScenePage . Instance . OnSceneChange ( ) ;
89- SearchPage . Instance . OnSceneChange ( ) ;
90- }
49+ ScenePage . Instance ? . OnSceneChange ( ) ;
50+ SearchPage . Instance ? . OnSceneChange ( ) ;
9151 }
9252
93- // Update
9453 public override void OnUpdate ( )
9554 {
9655 if ( Input . GetKeyDown ( KeyCode . F7 ) )
@@ -109,43 +68,7 @@ public override void OnUpdate()
10968 MainMenu . Instance . Update ( ) ;
11069 WindowManager . Instance . Update ( ) ;
11170
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 ( ) ;
14972 }
15073 }
15174
@@ -156,79 +79,7 @@ public override void OnGUI()
15679 MainMenu . Instance . OnGUI ( ) ;
15780 WindowManager . Instance . OnGUI ( ) ;
15881
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 ( ) ;
23283 }
23384 }
23485}
0 commit comments