/// <summary> /// Play the specified audio clip with the given parameters (and follow a given Transform while playing). /// Returns a reference to the SoundyController that is playing the sound. /// Returns null if the AudioClip is null. /// </summary> /// <param name="audioClip"> The AudioClip to play </param> /// <param name="outputAudioMixerGroup"> The output audio mixer group that this sound will get routed through </param> /// <param name="followTarget"> The target transform that the sound will follow while playing </param> /// <param name="volume"> The volume of the audio source (0.0 to 1.0) </param> /// <param name="pitch"> The pitch of the audio source </param> /// <param name="loop"> Is the audio clip looping? </param> /// <param name="spatialBlend"> /// Sets how much this AudioSource is affected by 3D space calculations (attenuation, /// doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D /// </param> public static SoundyController Play(AudioClip audioClip, AudioMixerGroup outputAudioMixerGroup, Transform followTarget = null, float volume = 1, float pitch = 1, bool loop = false, float spatialBlend = 1) { if (!s_initialized) { s_instance = Instance; } if (audioClip == null) { return(null); } SoundyController controller = SoundyPooler.GetControllerFromPool(); controller.SetSourceProperties(audioClip, volume, pitch, loop, spatialBlend); controller.SetOutputAudioMixerGroup(outputAudioMixerGroup); if (followTarget == null) { spatialBlend = 0; controller.SetFollowTarget(Pooler.transform); } else { controller.SetFollowTarget(followTarget); } controller.gameObject.name = "[AudioClip]-(" + audioClip.name + ")"; controller.Play(); if (Instance.DebugComponent) { DDebug.Log("Play '" + audioClip.name + "' AudioClip", Instance); } return(controller); }
/// <summary> Target AudioSource stops playing </summary> public void Stop() { Unpause(); Unmute(); AudioSource.Stop(); m_isPlaying = false; if (DebugComponent) DDebug.Log("Stop '" + name + "' SoundyController", this); ResetController(); SoundyPooler.PutControllerInPool(this); }
/// <summary> Initializes the SoundyManager Instance </summary> public static void Init() { if (s_initialized || s_instance != null) { return; } s_instance = Instance; for (int i = 0; i < SoundyPooler.MinimumNumberOfControllers + 1; i++) { SoundyPooler.GetControllerFromPool().Stop(); } }
/// <summary> Plays one of the sounds from the AudioClip list, with the set randomized values, at the specified position </summary> /// <param name="position"> The world position where this sound will be played at </param> /// <param name="outputAudioMixerGroup"> The output AudioMixerGroup that the sound will get routed through </param> public SoundyController Play(Vector3 position, AudioMixerGroup outputAudioMixerGroup = null) { SoundyController controller = SoundyPooler.GetControllerFromPool(); m_lastPlayedAudioData = GetAudioData(Mode); controller.SetSourceProperties(m_lastPlayedAudioData.AudioClip, RandomVolume, RandomPitch, Loop, SpatialBlend); controller.SetOutputAudioMixerGroup(outputAudioMixerGroup); controller.SetPosition(position); if (m_lastPlayedAudioData == null) { return(controller); } controller.gameObject.name = "[" + SoundName + "]-(" + m_lastPlayedAudioData.AudioClip.name + ")"; controller.Play(); return(controller); }
/// <summary> /// Play the specified audio clip with the given parameters, at the set position. /// Returns a reference to the SoundyController that is playing the sound. /// Returns null if the AudioClip is null. /// </summary> /// <param name="audioClip"> The AudioClip to play </param> /// <param name="outputAudioMixerGroup"> The output audio mixer group that this sound will get routed through </param> /// <param name="position"> The position from where this sound will play from </param> /// <param name="volume"> The volume of the audio source (0.0 to 1.0) </param> /// <param name="pitch"> The pitch of the audio source </param> /// <param name="loop"> Is the audio clip looping? </param> /// <param name="spatialBlend"> /// Sets how much this AudioSource is affected by 3D space calculations (attenuation, /// doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D /// </param> public static SoundyController Play(AudioClip audioClip, AudioMixerGroup outputAudioMixerGroup, Vector3 position, float volume = 1, float pitch = 1, bool loop = false, float spatialBlend = 0) { if (!s_initialized) { s_instance = Instance; } if (audioClip == null) { return(null); } SoundyController controller = SoundyPooler.GetControllerFromPool(); controller.SetSourceProperties(audioClip, volume, pitch, loop, spatialBlend); controller.SetOutputAudioMixerGroup(outputAudioMixerGroup); controller.SetPosition(position); controller.Play(); if (Instance.DebugComponent) { DDebug.Log("Play '" + audioClip.name + "' AudioClip", Instance); } return(controller); }
public void ResetComponent(SoundyPooler pooler) { }
private static void RunOnStart() { ApplicationIsQuitting = false; s_initialized = false; s_pooler = null; }