1 using UnityEngine.Audio;
5 public class AudioManager : MonoBehaviour
8 public AudioSource currentSource;
9 public static AudioManager instance;
23 DontDestroyOnLoad(gameObject);
25 foreach (Sound s in sounds)
27 s.source = gameObject.AddComponent<AudioSource>();
28 s.source.clip = s.clip;
30 s.source.volume = s.volume;
31 s.source.pitch = s.pitch;
35 public void Play(string name)
37 Sound s = Array.Find(sounds, sound => sound.name == name);
38 currentSource = s.source;