From 3d1f783f19c72898c7c6e8a945212e3efeac980d Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Sun, 4 Feb 2024 08:19:38 +0100 Subject: [PATCH] Added stop all Audio --- Assets/Scripts/Managers/AudioManager/AudioManager.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Assets/Scripts/Managers/AudioManager/AudioManager.cs b/Assets/Scripts/Managers/AudioManager/AudioManager.cs index b50dae8..32d0311 100644 --- a/Assets/Scripts/Managers/AudioManager/AudioManager.cs +++ b/Assets/Scripts/Managers/AudioManager/AudioManager.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using Unity.VisualScripting; using UnityEngine; +using static Unity.VisualScripting.Member; public class AudioManager : MonoBehaviour @@ -93,6 +94,17 @@ public class AudioManager : MonoBehaviour yield return new WaitForSecondsRealtime(0.05f); } } + + public static void StopAllAudio() + { + foreach (SoundSource item in AliveSources) + { + item.source.Stop(); + Destroy(item.source.gameObject); + } + + AliveSources.Clear(); + } } public class SoundSource