// Use this for initialization void Start () { if (instance == null) instance = this; else if (instance != this) Destroy (gameObject); DontDestroyOnLoad (gameObject); }
void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } foreach (Sound s in sounds) { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.outputAudioMixerGroup = s.mixer; s.source.volume = s.volume; s.source.pitch = s.pitch; s.source.loop = s.loop; } }