Exemplo n.º 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.");
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Instructs the AudioSource to play a single clip, with optional looping, in a position in 3D space.
        /// </summary>
        public void PlayAudioClip(AudioClip clip, AudioConfigurationSO config, bool loop, Vector3 position = default)
        {
            transform.position = position;

            config.ApplyToSource(source);

            source.clip = clip;
            source.loop = loop;
            source.Play();

            if (!loop)
            {
                StartCoroutine(WaitForAudioFinish(clip.length));
            }
        }
Exemplo n.º 3
0
        /// <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;
                }
            }
        }