diff --git a/Assets/Scripts/AudioManager.cs b/Assets/Scripts/AudioManager.cs index d57b057..da1c815 100644 --- a/Assets/Scripts/AudioManager.cs +++ b/Assets/Scripts/AudioManager.cs @@ -10,12 +10,15 @@ public class AudioManager : MonoBehaviour // Start is called before the first frame update public void Awake() { + DontDestroyGameobjectOnLoad(gameObject); foreach (AudioSound c in clips) { c.source = gameObject.AddComponent(); c.source.clip = c.clip; c.source.volume = c.volume; c.source.pitch = c.pitch; + c.source.loop = c.loop; + } } @@ -23,6 +26,9 @@ public class AudioManager : MonoBehaviour public void Play(string name) { AudioSound s = Array.Find(clips, sound => sound.name == name); + if (s == null) { + return; + } s.source.Play(); } } diff --git a/Assets/Scripts/AudioSound.cs b/Assets/Scripts/AudioSound.cs index 86ab634..bb7a273 100644 --- a/Assets/Scripts/AudioSound.cs +++ b/Assets/Scripts/AudioSound.cs @@ -12,6 +12,8 @@ public class AudioSound [Range(0.1f, 3f)] public float pitch; + public bool loop = false; + [HideInInspector] public AudioSource source; }