]> git.lizzy.rs Git - SuperMouseAdventure.git/blobdiff - 2DGame/Assets/Scripts/Audio/AudioManager.cs
Improved Audio and improved dust effect
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Audio / AudioManager.cs
index a91169d2e678484a7ed6ee14cb4511d8d0e08740..3092af2bc8b20fb90a0b519e66d21b5c69f43f2a 100644 (file)
@@ -5,22 +5,10 @@ using UnityEngine;
 public class AudioManager : MonoBehaviour
 {
     public Sound[] sounds;
-    public static AudioManager instance;
+    public string music;
 
     void Awake()
     {
-        if (instance == null)
-        {
-            instance = this;
-        }
-        else
-        {
-            Destroy(gameObject);
-            return;
-        }
-
-        DontDestroyOnLoad(gameObject);
-
         foreach (Sound s in sounds)
         {
             s.source = gameObject.AddComponent<AudioSource>();
@@ -31,15 +19,20 @@ public class AudioManager : MonoBehaviour
         }
     }
 
+    void Start()
+    {
+        FindObjectOfType<AudioManager>().Play(music);
+    }
+
     public void Play(string name)
     {
         Sound s = Array.Find(sounds, sound => sound.name == name);
         s.source.Play();
     }
 
-    public void Stop(string sound)
+    public void Stop(string name)
     {
-        Sound s = Array.Find(sounds, item => item.name == sound);
+        Sound s = Array.Find(sounds, sound => sound.name == name);
         s.source.Stop();
     }
 }
\ No newline at end of file