Exemplo n.º 1
0
 /// <summary>
 /// Three parameter constructor.
 /// </summary>
 /// <param name="audioClip">The clip that should be played.</param>
 /// <param name="audioConfig">A reference to the overridden AudioConfig.</param>
 /// <param name="audioModifier">A reference to the overridden AudioModifier.</param>
 public AudioClipInfo(AudioClip audioClip, AudioConfig audioConfig, AudioModifier audioModifier)
 {
     m_ClipIndex     = -1;
     m_AudioClip     = audioClip;
     m_AudioConfig   = audioConfig;
     m_AudioModifier = audioModifier;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Three parameter constructor.
 /// </summary>
 /// <param name="clipIndex">The index of the AudioClip inside the AudioConfig.</param>
 /// <param name="audioConfig">A reference to the overridden AudioConfig.</param>
 /// <param name="audioModifier">A reference to the overridden AudioModifier.</param>
 public AudioClipInfo(int clipIndex, AudioConfig audioConfig, AudioModifier audioModifier)
 {
     m_ClipIndex     = clipIndex;
     m_AudioClip     = null;
     m_AudioConfig   = audioConfig;
     m_AudioModifier = audioModifier;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Two parameter constructor.
 /// </summary>
 /// <param name="audioClip">The clip that should be played.</param>
 /// <param name="audioConfig">A reference to the overridden AudioConfig.</param>
 public AudioClipInfo(AudioClip audioClip, AudioConfig audioConfig)
 {
     m_ClipIndex     = -1;
     m_AudioClip     = audioClip;
     m_AudioConfig   = audioConfig;
     m_AudioModifier = new AudioModifier();
 }
Exemplo n.º 4
0
 /// <summary>
 /// One parameter constructor which copies another AudioClipInfo.
 /// </summary>
 /// <param name="audioClipInfo">The AudioClipInfo that should be copied.</param>
 public AudioClipInfo(AudioClipInfo audioClipInfo)
 {
     m_ClipIndex     = audioClipInfo.m_ClipIndex;
     m_AudioClip     = audioClipInfo.m_AudioClip;
     m_AudioConfig   = audioClipInfo.m_AudioConfig;
     m_AudioModifier = audioClipInfo.m_AudioModifier;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Plays the audio clip with a random set index.
        /// </summary>
        /// <param name="gameObject">The GameObject that is playing the audio clip.</param>
        /// <param name="audioModifier">The AudioModifier that should override the AudioSource settings.</param>
        /// <param name="clipIndex">The index of the AudioClip that should be played.</param>
        /// <returns>The result of playing the AudioClip.</returns>
        public PlayResult PlayAudioClip(GameObject gameObject, AudioModifier audioModifier, int clipIndex = -1)
        {
            var audioClipInfo = GetAudioClipInfo(clipIndex);

            audioClipInfo    = new AudioClipInfo(audioClipInfo, audioModifier);
            m_LastPlayResult = AudioManager.Play(gameObject, audioClipInfo);
            return(m_LastPlayResult);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Two parameter constructor.
        /// </summary>
        /// <param name="clipIndex">The index of the AudioClip inside the AudioConfig.</param>
        /// <param name="audioConfig">A reference to the overridden AudioConfig.</param>
        public AudioClipInfo(int clipIndex, AudioConfig audioConfig)
        {
            m_ClipIndex = clipIndex;
            m_AudioClip = audioConfig != null?audioConfig.GetAudioClip(clipIndex) : null;

            m_AudioConfig   = audioConfig;
            m_AudioModifier = new AudioModifier();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Internal method which plays the audio clip at the specified position.
        /// </summary>
        /// <param name="clip">The clip that should be played.</param>
        /// <param name="position">The position that the clip should be played at.</param>
        /// <param name="volume">The volume to play the clip at.</param>
        /// <param name="pitch">The pitch to play the clip at.</param>
        /// <returns>The result of playing the AudioClip.</returns>
        protected virtual PlayResult PlayAtPositionInternal(AudioClip clip, Vector3 position, float volume, float pitch)
        {
            var audioModifier = new AudioModifier();

            if (volume > -1)
            {
                audioModifier.VolumeOverride = new FloatOverride(FloatOverride.Override.Constant, volume);
            }
            if (pitch > -1)
            {
                audioModifier.PitchOverride = new FloatOverride(FloatOverride.Override.Constant, pitch);
            }
            return(m_AudioManagerModule.PlayAtPosition(m_GameObject, new AudioClipInfo(clip, null, audioModifier), position));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Internal method which plays the audio clip.
        /// </summary>
        /// <param name="playGameObject">The GameObject that is playing the audio clip.</param>
        /// <param name="clip">The clip to play.</param>
        /// <param name="volume">The volume to play the clip at.</param>
        /// <param name="pitch">The pitch to play the clip at.</param>
        /// <param name="loop">Does the clip loop?</param>
        /// <param name="delay">The number of seconds to delay the clip from playing.</param>
        /// <returns>The AudioSource that is playing the AudioClip (can be null).</returns>
        protected virtual PlayResult PlayInternal(GameObject playGameObject, AudioClip clip, float volume, float pitch, bool loop, float delay)
        {
            var audioModifier = new AudioModifier();

            audioModifier.LoopOverride = new BoolOverride(BoolOverride.Override.Constant, loop);
            if (volume > -1)
            {
                audioModifier.VolumeOverride = new FloatOverride(FloatOverride.Override.Constant, volume);
            }
            if (pitch > -1)
            {
                audioModifier.PitchOverride = new FloatOverride(FloatOverride.Override.Constant, pitch);
            }
            if (delay > -1)
            {
                audioModifier.DelayOverride = new FloatOverride(FloatOverride.Override.Constant, delay);
            }
            return(PlayInternal(playGameObject, new AudioClipInfo(clip, null, audioModifier)));
        }