1 using UnityEngine.Audio;
5 public class AudioManager : MonoBehaviour
8 public static AudioManager instance;
22 DontDestroyOnLoad(gameObject);
24 foreach (Sound s in sounds)
26 s.source = gameObject.AddComponent<AudioSource>();
27 s.source.clip = s.clip;
29 s.source.volume = s.volume;
30 s.source.pitch = s.pitch;
34 public void Play(string name)
36 Sound s = Array.Find(sounds, sound => sound.name == name);