diff --git a/Nautilus/Utility/MaterialUtils.cs b/Nautilus/Utility/MaterialUtils.cs index 8c146ac8..90d06048 100644 --- a/Nautilus/Utility/MaterialUtils.cs +++ b/Nautilus/Utility/MaterialUtils.cs @@ -23,7 +23,7 @@ internal static void Patch() _sceneEventAdded = true; } } - + private static IEnumerator LoadReferences() { yield return PatchInternal(); @@ -337,6 +337,6 @@ private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.name != "MenuEnvironment") return; - CoroutineHost.StartCoroutine(LoadReferences()); + CoroutineHost.StartCoroutine(ReloadStaleReferences()); } } diff --git a/Nautilus/Utility/MaterialUtils_BelowZero.cs b/Nautilus/Utility/MaterialUtils_BelowZero.cs index a126260a..ce8bd8c1 100644 --- a/Nautilus/Utility/MaterialUtils_BelowZero.cs +++ b/Nautilus/Utility/MaterialUtils_BelowZero.cs @@ -42,6 +42,16 @@ private static IEnumerator LoadGlassMaterials() InteriorGlassMaterial.SetFloat("_Shininess", 6f); InteriorGlassMaterial.SetFloat("_Fresnel", 0.88f); } + + private static IEnumerator ReloadStaleReferences() + { + Object.Destroy(GlassMaterial); + Object.Destroy(ExteriorGlassMaterial); + Object.Destroy(ShinyGlassMaterial); + Object.Destroy(InteriorGlassMaterial); + + yield return LoadGlassMaterials(); + } } #endif \ No newline at end of file diff --git a/Nautilus/Utility/MaterialUtils_Subnautica.cs b/Nautilus/Utility/MaterialUtils_Subnautica.cs index c1bc7d46..b2bf1031 100644 --- a/Nautilus/Utility/MaterialUtils_Subnautica.cs +++ b/Nautilus/Utility/MaterialUtils_Subnautica.cs @@ -184,9 +184,20 @@ private static void OnCyclopsLoaded(GameObject cyclops) var holoMat = cyclops.transform.Find("HelmHUD/HelmHUDVisuals/Canvas_LeftHUD/EngineOnUI/EngineOff_Button") .GetComponent().material; - Object.Destroy(HolographicUIMaterial); HolographicUIMaterial = new Material(holoMat); _cyclopsLoaded = true; } + + private static IEnumerator ReloadStaleReferences() + { + Object.Destroy(GlassMaterial); + Object.Destroy(ExteriorGlassMaterial); + Object.Destroy(ShinyGlassMaterial); + Object.Destroy(InteriorGlassMaterial); + Object.Destroy(HolographicUIMaterial); + + yield return LoadGlassMaterials(); + yield return LoadUIMaterial(); + } } #endif \ No newline at end of file