From 2d328229c93ca8639f1de6241e0a7c4fa05eadb8 Mon Sep 17 00:00:00 2001 From: Slaith <34562469+Slaith12@users.noreply.github.com> Date: Sun, 6 Mar 2022 19:56:45 -0800 Subject: [PATCH] Gave sound objects a little more functionality --- Assets/Scripts/Util/MultiSound.cs | 11 +++++++++-- Assets/Scripts/Util/Sound.cs | 8 +++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Util/MultiSound.cs b/Assets/Scripts/Util/MultiSound.cs index 270094ff..9e6b441b 100644 --- a/Assets/Scripts/Util/MultiSound.cs +++ b/Assets/Scripts/Util/MultiSound.cs @@ -25,7 +25,7 @@ namespace RhythmHeavenMania.Util } - public static void Play(Sound[] snds, bool game = true) + public static MultiSound Play(Sound[] snds, bool game = true) { List sounds = snds.ToList(); GameObject gameObj = new GameObject(); @@ -36,6 +36,7 @@ namespace RhythmHeavenMania.Util gameObj.name = "MultiSound"; GameManager.instance.SoundObjects.Add(gameObj); + return ms; } private void Update() @@ -57,8 +58,14 @@ namespace RhythmHeavenMania.Util if (songPositionInBeats >= (sounds[sounds.Count - 1].beat)) { - Destroy(this.gameObject); + Delete(); } } + + public void Delete() + { + GameManager.instance.SoundObjects.Remove(gameObject); + Destroy(gameObject); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Util/Sound.cs b/Assets/Scripts/Util/Sound.cs index b4b13799..4e5773c3 100644 --- a/Assets/Scripts/Util/Sound.cs +++ b/Assets/Scripts/Util/Sound.cs @@ -70,7 +70,13 @@ namespace RhythmHeavenMania.Util IEnumerator NotRelyOnBeatSound() { yield return new WaitForSeconds(clip.length); - Destroy(this.gameObject); + Delete(); + } + + public void Delete() + { + GameManager.instance.SoundObjects.Remove(gameObject); + Destroy(gameObject); } } }