public void Start() { var audioObject = GameObject.FindGameObjectWithTag(Tag.Audio); _audioControl = audioObject.GetComponent <AudioControl>(); GetComponent <Button>().onClick.AddListener(() => { _audioControl.PlayAudioClip(AudioType); }); }
private void Awake() { var audioObject = GameObject.FindGameObjectWithTag(Tag.Audio); _audioControl = audioObject.GetComponent <AudioControl>(); if (PlayOnAwake) { _audioControl.PlayAudioClip(AudioType); } }