Example #1
0
 public void RaiseEvent(AudioConfigurationSO config, AudioCueSO cue, Vector3 position)
 {
     if (OnRequestRaised != null)
     {
         OnRequestRaised(config, cue, position);
     }
     else
     {
         Debug.LogWarning("An AudioCue was requested, but nobody picked it up. " +
                          "Check why there is no AudioManager already loaded, " +
                          "and make sure it's listening on this AudioCue Event channel.");
     }
 }
        /// <summary>
        /// Plays audio based on given configuration, cue object and position
        /// </summary>
        /// <param name="config"></param>
        /// <param name="audioCue"></param>
        /// <param name="position"></param>
        public void PlayAudioCue(AudioConfigurationSO config, AudioCueSO audioCue, Vector3 position = default)
        {
            //play each clip provided by the audio cue
            foreach (AudioClip clip in audioCue.GetClips())
            {
                AudioEmitter emitter = emitterPool.Request();
                emitter.PlayAudioClip(clip, config, audioCue.loop, position);

                activeEmitters.Add(emitter);

                if (!audioCue.loop)
                {
                    //if an emitter is not going to loop, wait for it to finish to return it to the pool
                    emitter.OnAudioFinishedPlaying += ReturnAudioEmitter;
                }
            }
        }