void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); foreach (Sound s in sounds) { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.volume = s.volume; s.source.pitch = s.pitch; s.source.loop = s.loop; } }
private void Awake() { audioManager = PersistentAudioManager.Instance; //GameObject.FindGameObjectWithTag("AudioManager").GetComponent<PersistentAudioManager>(); audioSource = GetComponent <AudioSource>(); }