diff options
Diffstat (limited to 'Assets/Scripts/AudioManager.cs')
-rw-r--r-- | Assets/Scripts/AudioManager.cs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/Assets/Scripts/AudioManager.cs b/Assets/Scripts/AudioManager.cs index 1809375..ccb8ebc 100644 --- a/Assets/Scripts/AudioManager.cs +++ b/Assets/Scripts/AudioManager.cs @@ -6,18 +6,8 @@ public class AudioManager : MonoBehaviour { public Sound[] sounds; - public static AudioManager instance; - private void Awake() { - if (instance == null) instance = this; - else { - Destroy(gameObject); - return; - } - - DontDestroyOnLoad(gameObject); - foreach (Sound s in sounds) { s.source = gameObject.AddComponent<AudioSource>(); s.source.clip = s.clip; @@ -41,4 +31,18 @@ public class AudioManager : MonoBehaviour } s.source.Play(); } + + public void Stop(string name) + { + Sound s = Array.Find(sounds, sound => sound.name == name); + if (s == null) return; + s.source.Stop(); + } + + public bool isPlaying(string name) + { + Sound s = Array.Find(sounds, sound => sound.name == name); + if (s == null) return false; + return s.source.isPlaying; + } } |