public static void PlaySound(SFXController.Sounds sound) { SoundEmitter emitter = SFXController.Instance.GetEmitter(sound); AudioSource source = emitter.GetSource(); if (!source.isPlaying || emitter.interupt) { source.clip = SFXController.Instance.GetRandomClip(emitter); source.Play(); } }
private SoundEmitter GetEmitter(SFXController.Sounds sound) { foreach (SoundEmitter soundEmitter in this.emitters) { if (soundEmitter.sound == sound) { return(soundEmitter); } } Debug.Log(string.Format("There is no sound emitter created for {0}", sound), this); return(null); }