Skip to content

Commit

Permalink
Moved reference reloading to partial classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Indigocoder1 committed Dec 25, 2024
1 parent 8cbe4cc commit 70d6276
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Nautilus/Utility/MaterialUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static void Patch()
_sceneEventAdded = true;
}
}

private static IEnumerator LoadReferences()
{
yield return PatchInternal();
Expand Down Expand Up @@ -337,6 +337,6 @@ private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (scene.name != "MenuEnvironment") return;

CoroutineHost.StartCoroutine(LoadReferences());
CoroutineHost.StartCoroutine(ReloadStaleReferences());
}
}
10 changes: 10 additions & 0 deletions Nautilus/Utility/MaterialUtils_BelowZero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 12 additions & 1 deletion Nautilus/Utility/MaterialUtils_Subnautica.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,20 @@ private static void OnCyclopsLoaded(GameObject cyclops)
var holoMat = cyclops.transform.Find("HelmHUD/HelmHUDVisuals/Canvas_LeftHUD/EngineOnUI/EngineOff_Button")
.GetComponent<UnityEngine.UI.Image>().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

0 comments on commit 70d6276

Please sign in to comment.