From 1d564b4910cb68ca59752148c7b1e1289a3c85c0 Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Mon, 7 Mar 2022 02:41:07 -0700 Subject: [PATCH] Fixed some errors --- Assets/Scripts/GameManager.cs | 3 +++ Assets/Scripts/Util/Jukebox.cs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index ac338b95..a244b34b 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -230,6 +230,7 @@ namespace RhythmHeavenMania public void Pause() { Conductor.instance.Pause(); + KillAllSounds(); } public void Stop(float beat) @@ -244,6 +245,8 @@ namespace RhythmHeavenMania { for (int i = 0; i < SoundObjects.Count; i++) Destroy(SoundObjects[i].gameObject); + + SoundObjects.Clear(); } #endregion diff --git a/Assets/Scripts/Util/Jukebox.cs b/Assets/Scripts/Util/Jukebox.cs index 953a44ce..3e6945a3 100644 --- a/Assets/Scripts/Util/Jukebox.cs +++ b/Assets/Scripts/Util/Jukebox.cs @@ -109,6 +109,10 @@ namespace RhythmHeavenMania.Util public static void KillLoop(AudioSource source, float fadeTime) { + // Safeguard against previously-destroyed sounds. + if (source == null) + return; + source.GetComponent().KillLoop(fadeTime); } }