File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,9 +31,16 @@ public class WorldBoxMod : MonoBehaviour
3131 private bool initialized = false ;
3232 private bool initialized_successfully = false ;
3333
34- [ HarmonyPatch ( typeof ( Assembly ) , nameof ( Assembly . LoadFrom ) , typeof ( string ) ) ]
35- [ HarmonyReversePatch ]
36- private static Assembly LoadFrom ( string path ) => throw new NotImplementedException ( ) ;
34+ private static void UnityExplorerFix ( ) {
35+ Harmony harmony = new Harmony ( Others . harmony_id ) ;
36+ MethodInfo original = AccessTools . Method ( typeof ( Assembly ) , nameof ( Assembly . LoadFrom ) , new [ ] { typeof ( string ) } ) ;
37+ MethodInfo standin = AccessTools . Method ( typeof ( WorldBoxMod ) , nameof ( LoadFrom ) ) ;
38+ ReversePatcher reversePatcher = harmony . CreateReversePatcher ( original , new HarmonyMethod ( standin ) ) ;
39+
40+ reversePatcher . Patch ( ) ;
41+ }
42+
43+ private static Assembly LoadFrom ( string path ) => Assembly . LoadFrom ( path ) ;
3744
3845 private void Start ( )
3946 {
@@ -46,7 +53,10 @@ private void Start()
4653
4754 LogService . Init ( ) ;
4855
49- Harmony . CreateAndPatchAll ( typeof ( WorldBoxMod ) , Others . harmony_id ) ;
56+ if ( ReflectionHelper . IsAssemblyLoaded ( "0Harmony" ) ) {
57+ UnityExplorerFix ( ) ;
58+ }
59+
5060 fileSystemInitialize ( ) ;
5161 LogService . LogInfo ( $ "NeoModLoader Version: { InternalResourcesGetter . GetCommit ( ) } ") ;
5262 }
Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ namespace NeoModLoader.utils;
77
88internal static class ReflectionHelper
99{
10+ internal static bool IsAssemblyLoaded ( string assembly_name ) {
11+ return AppDomain . CurrentDomain . GetAssemblies ( ) . Any ( a => a . GetName ( ) . Name . Equals ( assembly_name ) ) ;
12+ }
13+
1014 internal static Delegate GetMethod < T > ( string method_name , bool is_static = false )
1115 {
1216 return createMethodDelegate ( is_static
You can’t perform that action at this time.
0 commit comments