From f4f586c34a867b6f4148aecf91565df7a44fea2a Mon Sep 17 00:00:00 2001 From: Lisias T Date: Fri, 21 Apr 2023 04:11:32 -0300 Subject: [PATCH] Moving the MeshEngine init to the end of the Loading Scene to allow it to fectch any changes made to the GameDatabase by Module Manager. This will help solve problems for ReStock, but algo to everybody else that change models. https://github.com/net-lisias-ksp/DistantObject/issues/1 --- Source/DistantObject/Startup.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Source/DistantObject/Startup.cs b/Source/DistantObject/Startup.cs index d7184f5..1c7b2c7 100644 --- a/Source/DistantObject/Startup.cs +++ b/Source/DistantObject/Startup.cs @@ -39,19 +39,13 @@ private void Awake() { KSPe.Util.Compatibility.Check(); KSPe.Util.Installation.Check(); + GameEvents.onGameSceneSwitchRequested.Add(OnGameSceneSwitchRequested); } catch (KSPe.Util.InstallmentException e) { Log.error(e.ToShortMessage()); KSPe.Common.Dialogs.ShowStopperAlertBox.Show(e); } - - { - using (KSPe.Util.SystemTools.Assembly.Loader a = new KSPe.Util.SystemTools.Assembly.Loader()) - { - a.LoadAndStartup("MeshEngine"); - } - } } [UsedImplicitly] @@ -59,5 +53,14 @@ private void Start() { Log.force("Version {0}", Version.Text); } + + private void OnGameSceneSwitchRequested(GameEvents.FromToAction data) + { + GameEvents.onGameSceneSwitchRequested.Remove(OnGameSceneSwitchRequested); + using (KSPe.Util.SystemTools.Assembly.Loader a = new KSPe.Util.SystemTools.Assembly.Loader()) + { + a.LoadAndStartup("MeshEngine"); + } + } } }