public void PlaySoundEffect(SoundInfor sound) { if (!IsSoundOn) { return; } AudioSource audioSource = GetAudioSource(); audioSource.clip = sound.Clip; audioSource.volume = sound.Volume; audioSource.Play(); }
public void PlayBackgroundMusic(SoundInfor sound = null) { if (sound != null) { _curBackgroundMusic = sound; } if (IsMusicOn) { if (sound == null) { _backgroundSource.clip = _curBackgroundMusic.Clip; _backgroundSource.volume = _curBackgroundMusic.Volume; _backgroundSource.Play(); } else { _backgroundSource.clip = sound.Clip; _backgroundSource.volume = sound.Volume; _backgroundSource.Play(); } } }