internal static void Initialize() { try { string basedir = Path.Combine(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MelonLoader"), "Dependencies"), "SupportModules"); string filepath = null; if (Imports.IsIl2CppGame()) { filepath = Path.Combine(basedir, "MelonLoader.Support.Il2Cpp.dll"); } else { if (File.Exists(Path.Combine(Imports.GetAssemblyDirectory(), "UnityEngine.CoreModule.dll"))) { filepath = Path.Combine(basedir, "MelonLoader.Support.Mono.dll"); } else { if (IsOldUnity()) { filepath = Path.Combine(basedir, "MelonLoader.Support.Mono.Pre2017.2.dll"); } else { filepath = Path.Combine(basedir, "MelonLoader.Support.Mono.Pre2017.dll"); } } } if (File.Exists(filepath)) { byte[] data = File.ReadAllBytes(filepath); if (data.Length > 0) { assembly = Assembly.Load(data); if (!assembly.Equals(null)) { type = assembly.GetType("MelonLoader.Support.Main"); if (!type.Equals(null)) { MethodInfo method = type.GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Static); if (!method.Equals(null)) { supportModule = (ISupportModule)method.Invoke(null, new object[0]); } } } } } else { MelonModLogger.LogError("Unable to load Support Module! Support Module is Missing!"); MelonModLogger.Log("------------------------------"); } } catch (Exception e) { MelonModLogger.LogError("Unable to load Support Module!\n" + e.ToString()); MelonModLogger.Log("------------------------------"); } }
internal static void Destroy() { supportModule?.Destroy(); supportModule = null; }