/**Play the sound using the mixer group provided.**/ private void PlaySound(SoundObject sound, AudioMixerGroup mixerGroup, bool restartIfPlayingAlready, bool playAsLoop, SoundConfiguration configurations) { if (configurations == null) { configurations = new SoundConfiguration(); } configurations.setIsLoop(playAsLoop); PlaySound(sound, mixerGroup, restartIfPlayingAlready, configurations); }
/**Search/Play and retrieve the sound specified using the mixer group provided**/ private SoundObject PlaySound(string soundName, AudioMixerGroup mixerGroup, bool restartIfPlayingAlready, bool playAsLoop, SoundConfiguration configurations) { if (configurations == null) { configurations = new SoundConfiguration(); } configurations.setIsLoop(playAsLoop); return(PlaySound(soundName, mixerGroup, restartIfPlayingAlready, configurations)); }
public virtual void Play(SoundConfiguration configurations) { if (configurations != null) { volume = configurations.volume < 0 ? volume:configurations.volume; fadeInTime = configurations.fadeInTime < 0 ? fadeInTime:configurations.fadeInTime; fadeOutTime = configurations.fadeOutTime < 0 ? fadeOutTime:configurations.fadeOutTime; if (configurations.loopHasChanged()) { isLoop = configurations.getLoopValue(); } } PlayRandomClip(true); }
/** * Starts playing the first clip. **/ override public void Play(SoundConfiguration configurations) { if (isEmpty()) { //nothing to play Debug.LogWarning("There is no AudioClip on: " + soundName + " to play."); return; } if (configurations != null) { volume = configurations.volume < 0 ? volume:configurations.volume; fadeInTime = configurations.fadeInTime < 0 ? fadeInTime:configurations.fadeInTime; fadeOutTime = configurations.fadeOutTime < 0 ? fadeOutTime:configurations.fadeOutTime; if (configurations.loopHasChanged()) { isLoop = configurations.getLoopValue(); } } PlayClipAt(0, true); }
private void PlaySound(SoundObject sound, AudioMixerGroup mixerGroup, bool restartIfPlayingAlready, SoundConfiguration configurations) { //The reproduction is allowed? if ((mixerGroup == fxGroup && !_FXAllowed) || (mixerGroup == musicGroup && !_MusicAllowed)) { /* * WARNING If the game logic use the returned sound on previous calls to wait for stop event we could have problems. * TODO Maybe play the sound with volume zero? Or dispatch stop right away? */ //Denied! return; } //We should avoid the PlayCall? if (!restartIfPlayingAlready && sound.isPlaying) { return; } //We store the audio so it can be globally paused/stoped playingSounds[mixerGroup][sound.soundName] = sound; sound.OnAudioStopped += OnAudioStopped; //correct group sound.audioSource.outputAudioMixerGroup = mixerGroup; sound.Play(configurations); }
private SoundObject PlaySound(string soundName, AudioMixerGroup mixerGroup, bool restartIfPlayingAlready, SoundConfiguration configurations) { //search for the object SoundObject sound = GetSoundByName(soundName); if (sound != null) { PlaySound(sound, mixerGroup, restartIfPlayingAlready, configurations); return(sound); } else { Debug.LogWarning("There is no sound with the name: " + soundName); } return(null); }
public void PlayMusic(SoundObject sound, bool restartIfPlayingAlready, bool playAsLoop, SoundConfiguration configurations) { PlaySound(sound, musicGroup, restartIfPlayingAlready, playAsLoop, configurations); }
public void PlayMusic(SoundObject sound, SoundConfiguration configurations) { PlaySound(sound, musicGroup, true, configurations); }
public SoundObject PlayMusic(string soundName, bool restartIfPlayingAlready, bool playAsLoop, SoundConfiguration configurations) { return(PlaySound(soundName, musicGroup, restartIfPlayingAlready, playAsLoop, configurations)); }
public SoundObject PlayMusic(string soundName, SoundConfiguration configurations) { return(PlaySound(soundName, musicGroup, true, configurations)); }
/** * Play the specified sound. * * restartIfPlayingAlready true-Play the sound no matter what * restartIfPlayingAlready false-Play only if it is not previously playing **/ public void PlayFX(SoundObject sound, bool restartIfPlayingAlready, SoundConfiguration configurations) { PlaySound(sound, fxGroup, restartIfPlayingAlready, configurations); }
public void PlayFX(SoundObject sound, SoundConfiguration configurations) { PlaySound(sound, fxGroup, true, configurations); }
/** * Search/Play and retrieve the specified sound. * * restartIfPlayingAlready true-Play the sound no matter what * restartIfPlayingAlready false-Play only if it is not previously playing **/ public SoundObject PlayFX(string soundName, bool restartIfPlayingAlready, SoundConfiguration configurations) { return(PlaySound(soundName, fxGroup, restartIfPlayingAlready, configurations)); }