private void PlayMusicIfExists(string audioName) { AudioFile audioFile = MusicFiles.Find(audio => audio.name.Equals(audioName)); if (audioFile == null) { return; } if (CurrentMusic.GetAudioSource() != null) { CurrentMusic.GetAudioSource().Stop(); } CurrentMusic = audioFile; CurrentMusic.GetAudioSource().Play(); }
private void PlaySFXIfExists(string audioName) { AudioFile audioFile = SFXFiles.Find(audio => audio.name.Equals(audioName)); if (audioFile == null) { return; } audioFile.GetAudioSource().Play(); }