Soundy Manager
Code examples to perform various interactions with the Soundy Manager
Get Controller
Create a new SoundyController in the current Scene and get a reference to it
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyController controller = SoundyManager.GetController(); } }
Init
Initialize the SoundyManager Instance
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.Init(); } }
Kill All Controllers
Stop all SoundyControllers from playing and destroys the GameObjects they are attached to
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.KillAllControllers(); } }
Mute All Controllers
Mute all the SoundyControllers
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.MuteAllControllers(); } }
Mute All Sounds
Mute all sound sources (including MasterAudio)
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.MuteAllSounds(); } }
Pause All Controllers
Pause all the SoundyControllers that are currently playing
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.PauseAllControllers(); } }
Pause All Sounds
Pause all sound sources (including MasterAudio)
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.PauseAllSounds(); } }
Stop All Controllers
Stop all the SoundyControllers that are currently playing
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.StopAllControllers(); } }
Stop all sound sources (including MasterAudio)
Description
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.StopAllSounds(); } }
Unmute All Controllers
Unmute all the SoundyControllers that were previously muted
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.UnmuteAllControllers(); } }
Unmute All Sounds
Unmute all sound sources (including MasterAudio)
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.UnmuteAllSounds(); } }
Unpause All Controllers
Unpause all the SoundyControllers that were previously paused
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.UnpauseAllControllers(); } }
Unpause All Sounds
Unpause all sound sources (including MasterAudio)
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { private void Start() { SoundyManager.UnpauseAllSounds(); } }
Play – Sound
Play the specified sound with the given category, name and type.
Returns a reference to the SoundyController that is playing the sound.
Returns null if no sound is found.
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { //The sound category public string MySoundDatabaseName; //Sound Name of the sound public string MySoundName; private void Start() { SoundyManager.Play(MySoundDatabaseName, MySoundName); } }
Play the specified sound at the given position.
Returns a reference to the SoundyController that is playing the sound.
Returns null if no sound is found.
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { //The sound category public string MySoundDatabaseName; //Sound Name of the sound public string MySoundName; //The position from where this sound will play from public Vector3 MyPosition; private void Start() { SoundyManager.Play(MySoundDatabaseName, MySoundName, MyPosition); } }
Play the specified sound and follow a given target Transform while playing.
Returns a reference to the SoundyController that is playing the sound.
Returns null if no sound is found.
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { //The sound category public string MySoundDatabaseName; //Sound Name of the sound public string MySoundName; //The target transform that the sound will follow while playing public Transform MyFollowTarget; private void Start() { SoundyManager.Play(MySoundDatabaseName, MySoundName, MyFollowTarget); } }
Play – SoundyData
Play a sound according to the settings in the SoundyData reference.
Returns a reference to the SoundyController that is playing the sound if data.SoundSource is set to either Soundy or AudioClip.
If data is null or data.SoundSource is set to MasterAudio, it will always return null because MasterAudio is the one playing the sound and not a SoundyController
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { //Sound settings (has a custom property drawer in the Inspector) public SoundyData MySoundyData; private void Start() { SoundyManager.Play(MySoundyData); } }
Play – AudioClip
Play the passed AudioClip.
Returns a reference to the SoundyController that is playing the sound.
Returns null if the AudioClip is null.
using Doozy.Engine.Soundy; using UnityEngine; public class ExampleClass : MonoBehaviour { public AudioClip MyAudioClip; private void Start() { SoundyManager.Play(MyAudioClip); } }
Play the specified AudioClip 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.
using Doozy.Engine.Soundy; using UnityEngine; using UnityEngine.Audio; public class ExampleClass : MonoBehaviour { //The AudioClip to play public AudioClip MyAudioClip; //The output audio mixer group that this sound will get routed through public AudioMixerGroup MyOutputAudioMixerGroup; //The position from where this sound will play from public Vector3 MyPosition; //The volume of the audio source (0.0 to 1.0) public float MyVolume = 1; //The pitch of the audio source public float MyPitch = 1; //Is the audio clip looping? public bool MyLoop = false; //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 public float MySpatialBlend = 1; private void Start() { //Play with default settings SoundyManager.Play(MyAudioClip, MyPosition); //Play with default settings and a custom Output AudioMixerGroup SoundyManager.Play(MyAudioClip, MyOutputAudioMixerGroup, MyPosition); //Play with all the settings SoundyManager.Play(MyAudioClip, MyOutputAudioMixerGroup, MyPosition, MyVolume, MyPitch, MyLoop, MySpatialBlend); } }
Play the specified AudioClip with the given parameters, and follow a target Transform (while playing)
Returns a reference to the SoundyController that is playing the sound.
Returns null if the AudioClip is null.
using Doozy.Engine.Soundy; using UnityEngine; using UnityEngine.Audio; public class ExampleClass : MonoBehaviour { //The AudioClip to play public AudioClip MyAudioClip; //The output audio mixer group that this sound will get routed through public AudioMixerGroup MyOutputAudioMixerGroup; //The target transform that the sound will follow while playing public Transform MyFollowTarget; //The volume of the audio source (0.0 to 1.0) public float MyVolume = 1; //The pitch of the audio source public float MyPitch = 1; //Is the audio clip looping? public bool MyLoop = false; //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 public float MySpatialBlend = 1; private void Start() { //Play with default settings SoundyManager.Play(MyAudioClip, MyFollowTarget); //Play with default settings and a custom OutputAudioMixerGroup SoundyManager.Play(MyAudioClip, MyOutputAudioMixerGroup, MyFollowTarget); //Play with all the settings SoundyManager.Play(MyAudioClip, MyOutputAudioMixerGroup, MyFollowTarget, MyVolume, MyPitch, MyLoop, MySpatialBlend); } }