Class CustomSoundHandler
A handler class for adding and overriding Sounds. Also see the AudioUtils class.
public static class CustomSoundHandler
- Inheritance
-
CustomSoundHandler
- Inherited Members
Methods
AttachChannelToGameObject(Channel, Transform)
Attaches the specified channel to the given transform. This results in the sound position following the
transform.public static void AttachChannelToGameObject(Channel channel, Transform transform)
Parameters
channelChannel- The channel to attach.
transformTransform- The transform which the channel will follow.
DetachChannelFromGameObject(Channel)
Detaches the specified channel from any game object.
public static void DetachChannelFromGameObject(Channel channel)
Parameters
channelChannel- The channel to detach.
RegisterCustomSound(string, Sound, Bus)
Register a Custom sound that has been loaded using AudioUtils. Some vanilla game sounds can be overridden by matching the id to the FMODAsset.path.
public static void RegisterCustomSound(string id, Sound sound, Bus bus)
Parameters
idstring- The Id of your custom sound which is used when checking which sounds to play.
soundSound- The pre loaded sound
busBus- The bus to play the sound on.
RegisterCustomSound(string, Sound, string)
Register a Custom sound that has been loaded using AudioUtils. Some vanilla game sounds can be overridden by matching the id to the FMODAsset.path.
public static void RegisterCustomSound(string id, Sound sound, string busPath)
Parameters
idstring- The Id of your custom sound which is used when checking which sounds to play.
soundSound- The pre loaded sound
busPathstring- The bus path to play the sound on.
RegisterCustomSound(string, IFModSound)
Registers a Custom sound by an IFModSound instance. IFModSound instances have custom logic for playing sounds.
public static void RegisterCustomSound(string id, IFModSound fModSound)
Parameters
idstring- The Id of your custom sound which is used when checking which sounds to play.
fModSoundIFModSound- The sound IFModSound object to register.
RegisterCustomSound(string, string, Bus, MODE)
Register a Custom sound by file path. Some vanilla game sounds can be overridden by matching the id to the FMODAsset.path.
public static Sound RegisterCustomSound(string id, string filePath, Bus bus, MODE mode = MODE.DEFAULT)
Parameters
idstring- The Id of your custom sound which is used when checking which sounds to play.
filePathstring- The file path on disk of the sound file to load.
busBus- The bus to play the sound on.
modeMODE- The audio MODE of the sound. Standard values of this property can be found in the AudioUtils class (i.e. StandardSoundModes_3D).
Returns
- Sound
- the FMOD.Sound loaded
RegisterCustomSound(string, string, string, MODE)
Register a Custom sound by file path. Some vanilla game sounds can be overridden by matching the id to the FMODAsset.path.
public static Sound RegisterCustomSound(string id, string filePath, string busPath, MODE mode = MODE.DEFAULT)
Parameters
idstring- The Id of your custom sound which is used when checking which sounds to play.
filePathstring- The file path on disk of the sound file to load.
busPathstring- The bus path to play the sound on.
modeMODE- The audio MODE of the sound. Standard values of this property can be found in the AudioUtils class (i.e. StandardSoundModes_3D).
Returns
- Sound
- the FMOD.Sound loaded
RegisterCustomSound(string, AudioClip, Bus, MODE)
Register a custom sound by an UnityEngine.AudioClip instance. Some vanilla game sounds can be overridden by matching the id to the FMODAsset.path.
public static Sound RegisterCustomSound(string id, AudioClip audio, Bus bus, MODE mode = MODE.DEFAULT)
Parameters
idstring- The Id of your custom sound which is used when checking which sounds to play.
audioAudioClip- The AudioClip to register.
busBus- The bus to play the sound on.
modeMODE- The audio MODE of the sound. Standard values of this property can be found in the AudioUtils class (i.e. StandardSoundModes_3D).
Returns
- Sound
- the FMOD.Sound loaded
RegisterCustomSound(string, AudioClip, string, MODE)
Register a custom sound by an UnityEngine.AudioClip instance. Some vanilla game sounds can be overridden by matching the id to the FMODAsset.path.
public static Sound RegisterCustomSound(string id, AudioClip audio, string busPath, MODE mode = MODE.DEFAULT)
Parameters
idstring- The Id of your custom sound which is used when checking which sounds to play.
audioAudioClip- The AudioClip to register.
busPathstring- The bus path to play the sound on.
modeMODE- The audio MODE of the sound. Standard values of this property can be found in the AudioUtils class (i.e. StandardSoundModes_3D).
Returns
- Sound
- the FMOD.Sound loaded
TryGetCustomSound(string, out Sound)
Try to get a registered custom FMOD.Sound.
public static bool TryGetCustomSound(string id, out Sound sound)
Parameters
idstring- The Id of the custom sound
soundSound- Outputs the FMOD.Sound if found and null if not found.
Returns
- bool
- true or false depending on if the id was found
TryGetCustomSoundChannel(int, out Channel)
Try to get a playing custom sound channel for an emitter
public static bool TryGetCustomSoundChannel(int id, out Channel channel)
Parameters
idint- The emitter's ID, can be retrieved by calling
object.GetInstanceID(). channelChannel- Outputs the FMOD.Channel.
Returns
- bool
- True if found, otherwise false.
TryPlayCustomSound(string, out Channel)
Try to find and play a custom FMOD.Sound that has been registered.
public static bool TryPlayCustomSound(string id, out Channel channel)
Parameters
idstring- The Id of the custom sound
channelChannel- the FMOD.Channel the sound is playing on.