From 9cc85135ddf55b07acba5d0f7d12690b2fb3618e Mon Sep 17 00:00:00 2001 From: ghorsington Date: Sun, 5 Jun 2022 19:02:25 +0300 Subject: [PATCH] Add temporary instance property to Unity and .NET chainloaders --- BepInEx.NetLauncher.Common/NetChainloader.cs | 11 ++++++++++- BepInEx.Unity/Bootstrap/UnityChainloader.cs | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/BepInEx.NetLauncher.Common/NetChainloader.cs b/BepInEx.NetLauncher.Common/NetChainloader.cs index 5d8a2a6..95c21e3 100644 --- a/BepInEx.NetLauncher.Common/NetChainloader.cs +++ b/BepInEx.NetLauncher.Common/NetChainloader.cs @@ -7,11 +7,20 @@ namespace BepInEx.NetLauncher.Common { public class NetChainloader : BaseChainloader { + // TODO: Remove once proper instance handling exists + public static NetChainloader Instance { get; set; } + + public override void Initialize(string gameExePath = null) + { + Instance = this; + base.Initialize(gameExePath); + } + public override BasePlugin LoadPlugin(PluginInfo pluginInfo, Assembly pluginAssembly) { var type = pluginAssembly.GetType(pluginInfo.TypeName); - var pluginInstance = (BasePlugin)Activator.CreateInstance(type); + var pluginInstance = (BasePlugin) Activator.CreateInstance(type); pluginInstance.Load(); diff --git a/BepInEx.Unity/Bootstrap/UnityChainloader.cs b/BepInEx.Unity/Bootstrap/UnityChainloader.cs index b3d1c7e..cc1e839 100644 --- a/BepInEx.Unity/Bootstrap/UnityChainloader.cs +++ b/BepInEx.Unity/Bootstrap/UnityChainloader.cs @@ -30,6 +30,9 @@ public class UnityChainloader : BaseChainloader private string _consoleTitle; + // TODO: Remove once proper instance handling exists + public static UnityChainloader Instance { get; set; } + /// /// The GameObject that all plugins are attached to as components. /// @@ -60,6 +63,8 @@ public class UnityChainloader : BaseChainloader public override void Initialize(string gameExePath = null) { + Instance = this; + UnityTomlTypeConverters.AddUnityEngineConverters(); ThreadingHelper.Initialize();