public void playSound(SoundOrMusic soundOrMusic) { if (soundOrMusic != null) { playSoundOnSource(soundOrMusic, specificAudioSource); } }
private static void playSoundFX(SoundOrMusic sound, AudioSource audioSource) { if ((sound != null) && (audioSource != null) && (audioSource.enabled)) { audioSource.PlayOneShot(sound.clip, sound.soundVolume); } }
private static void playSoundLoop(SoundOrMusic sound, AudioSource audioSource) { if ((sound != null) && (audioSource != null) && (audioSource.enabled)) { stopSoundLoop(audioSource); audioSource.clip = sound.clip; audioSource.loop = true; audioSource.volume = sound.soundVolume; audioSource.Play(); } }
public void playSoundOnSource(SoundOrMusic soundOrMusic, AudioSource audioSource) { if ((soundOrMusic != null) && (audioSource != null) && (audioSource.enabled)) { registerAudioSource(audioSource); if (soundOrMusic.loop) { playSoundLoop(soundOrMusic, audioSource); } else { playSoundFX(soundOrMusic, audioSource); } } }