4 using System.Collections.Generic;
16 private List<AudioSource> audioSources;
17 public List<AudioSource> AudioSources
27 var source = this.gameObject.AddComponent<AudioSource>();
28 source.playOnAwake =
false;
29 source.dopplerLevel = 0f;
30 source.enabled =
false;
31 audioSources.Add(source);
37 audioSources =
new List<AudioSource>();
38 foreach (AudioSource audioSource
in GetComponents<AudioSource>())
40 audioSources.Add(audioSource);
44 private void OnDestroy()
47 foreach (AudioSource audioSource
in audioSources)
49 Object.Destroy(audioSource);