Example #1
0
        public VoxAudioSource GetFreeVoxAudioSource(AudioModelType p_model = AudioModelType.DEFAULT)
        {
            VoxAudioSource __source = this.listVoxSources.FirstOrDefault(__t => __t.state == AudioSourceState.FREE) ?? this.AddAudioSourceToList();

            __source.state = AudioSourceState.USED;
            __source.CopyAudioProperties(_dictAudioSourceModels[p_model]);

            return(__source);
        }
Example #2
0
        /// @cond
                #endif

        /// <summary>
        /// Private function that actually creates SoundNode.
        /// </summary>
        private static SoundNode PlaySound(AudioClip p_clip, bool p_isLoop, float p_volume, string p_mixerName, string p_groupOutput, Transform p_target = null, AudioModelType p_model = AudioModelType.DEFAULT)
        {
            SoundNode __nodule = new SoundNode(SoundModule.instance.GetFreeVoxAudioSource(p_model), p_clip, p_isLoop, p_volume, p_mixerName, p_groupOutput, SoundModule.instance.GetNextNodeID());

            if (p_target != null)
            {
                // 3D Sound
                __nodule.VoxVoxSource.audioSource.spatialBlend = 1;
                __nodule.VoxVoxSource.targetTransform          = p_target;
            }
            else
            {
                // 2D Sound
                __nodule.VoxVoxSource.audioSource.spatialBlend = 0;
            }

            __nodule.Resume();

            SoundModule.instance.AddNode(__nodule);
            return(__nodule);
        }
Example #3
0
 /// <summary>
 /// Creates and plays SoundNode that ignores camera distance.
 /// </summary>
 /// <remarks>
 /// Creates and plays SoundNode that ignores camera distance. Useful for music or other sounds you always want to listen with the same volume.
 /// The function requires that you passes the name of the destined mixer and outputmixergroup.
 ///
 /// <code>
 ///
 /// Vox.SoundNode _backgroundMusic;
 /// public AudioClip _clip;
 ///
 /// public void PlayMusic()
 /// {
 ///     _backgroundMusic = Vox.MixedSound.Play2DSound(_clip, true, "GameplayMixer", "Music");
 /// }
 ///
 /// </code>
 ///
 /// </remarks>
 public static SoundNode Play2DSound(AudioClip p_clip, bool p_isLoop = false, float p_volume = 1, string p_mixerName = "", string p_groupOutput = "", AudioModelType p_model = AudioModelType.DEFAULT)
 {
     return(PlaySound(p_clip, p_isLoop, p_volume, p_mixerName, p_groupOutput, null, p_model));
 }