TopDown Engine  v4.1
MoreMountains.Tools.MMSoundManager Class Reference

A simple yet powerful sound manager, that will let you play sounds with an event based approach and performance in mind. More...

Inheritance diagram for MoreMountains.Tools.MMSoundManager:
MoreMountains.Tools.MMPersistentSingleton< MMSoundManager > MoreMountains.Tools.MMEventListener< MMSoundManagerTrackEvent > MoreMountains.Tools.MMEventListener< MMSoundManagerEvent > MoreMountains.Tools.MMEventListener< MMSoundManagerSoundControlEvent > MoreMountains.Tools.MMEventListener< MMSoundManagerSoundFadeEvent > MoreMountains.Tools.MMEventListener< MMSoundManagerAllSoundsControlEvent > MoreMountains.Tools.MMEventListener< MMSoundManagerTrackFadeEvent >

Public Types

enum  MMSoundManagerTracks {
  MMSoundManagerTracks.Sfx, MMSoundManagerTracks.Music, MMSoundManagerTracks.UI, MMSoundManagerTracks.Master,
  MMSoundManagerTracks.Other
}
 the possible ways to manage a track More...
 
enum  ControlTrackModes { ControlTrackModes.Mute, ControlTrackModes.Unmute, ControlTrackModes.SetVolume }
 A method that will let you mute/unmute a track, or set it to a specified volume More...
 

Public Member Functions

virtual AudioSource PlaySound (AudioClip audioClip, MMSoundManagerPlayOptions options)
 Plays a sound, separate options object signature More...
 
virtual AudioSource PlaySound (AudioClip audioClip, MMSoundManagerTracks mmSoundManagerTrack, Vector3 location, bool loop=false, float volume=1.0f, int ID=0, bool fade=false, float fadeInitialVolume=0f, float fadeDuration=1f, MMTweenType fadeTween=null, bool persistent=false, AudioSource recycleAudioSource=null, AudioMixerGroup audioGroup=null, float pitch=1f, float panStereo=0f, float spatialBlend=0.0f, bool soloSingleTrack=false, bool soloAllTracks=false, bool autoUnSoloOnEnd=false, bool bypassEffects=false, bool bypassListenerEffects=false, bool bypassReverbZones=false, int priority=128, float reverbZoneMix=1f, float dopplerLevel=1f, int spread=0, AudioRolloffMode rolloffMode=AudioRolloffMode.Logarithmic, float minDistance=1f, float maxDistance=500f, bool doNotAutoRecycleIfNotDonePlaying=false, float playbackTime=0f, float playbackDuration=0f, Transform attachToTransform=null, bool useSpreadCurve=false, AnimationCurve spreadCurve=null, bool useCustomRolloffCurve=false, AnimationCurve customRolloffCurve=null, bool useSpatialBlendCurve=false, AnimationCurve spatialBlendCurve=null, bool useReverbZoneMixCurve=false, AnimationCurve reverbZoneMixCurve=null)
 Plays a sound, signature with all options More...
 
virtual void PauseSound (AudioSource source)
 Pauses the specified audiosource More...
 
virtual void ResumeSound (AudioSource source)
 resumes play on the specified audio source More...
 
virtual void StopSound (AudioSource source)
 Stops the specified audio source More...
 
virtual void FreeSound (AudioSource source)
 Frees a specific sound, stopping it and returning it to the pool More...
 
virtual void MuteTrack (MMSoundManagerTracks track)
 Mutes an entire track More...
 
virtual void UnmuteTrack (MMSoundManagerTracks track)
 Unmutes an entire track More...
 
virtual void SetTrackVolume (MMSoundManagerTracks track, float volume)
 Sets the volume of an entire track More...
 
virtual float GetTrackVolume (MMSoundManagerTracks track, bool mutedVolume)
 Returns the current volume of a track More...
 
virtual void PauseTrack (MMSoundManagerTracks track)
 Pauses all sounds on a track More...
 
virtual void PlayTrack (MMSoundManagerTracks track)
 Plays or resumes all sounds on a track More...
 
virtual void StopTrack (MMSoundManagerTracks track)
 Stops all sounds on a track More...
 
virtual bool HasSoundsPlaying (MMSoundManagerTracks track)
 Returns true if sounds are currently playing on that track More...
 
virtual List< MMSoundManagerSoundGetSoundsPlaying (MMSoundManagerTracks track)
 Returns a list of MMSoundManagerSounds for the specified track More...
 
virtual void FreeTrack (MMSoundManagerTracks track)
 Stops all sounds on a track, and returns them to the pool More...
 
virtual void MuteMusic ()
 Mutes the music track, QoL method ready to bind to a UnityEvent More...
 
virtual void UnmuteMusic ()
 Unmutes the music track, QoL method ready to bind to a UnityEvent More...
 
virtual void MuteSfx ()
 Mutes the sfx track, QoL method ready to bind to a UnityEvent More...
 
virtual void UnmuteSfx ()
 Unmutes the sfx track, QoL method ready to bind to a UnityEvent More...
 
virtual void MuteUI ()
 Mutes the UI track, QoL method ready to bind to a UnityEvent More...
 
virtual void UnmuteUI ()
 Unmutes the UI track, QoL method ready to bind to a UnityEvent More...
 
virtual void MuteMaster ()
 Mutes the master track, QoL method ready to bind to a UnityEvent More...
 
virtual void UnmuteMaster ()
 Unmutes the master track, QoL method ready to bind to a UnityEvent More...
 
virtual void SetVolumeMusic (float newVolume)
 Sets the volume of the Music track to the specified value, QoL method, ready to bind to a UnityEvent More...
 
virtual void SetVolumeSfx (float newVolume)
 Sets the volume of the SFX track to the specified value, QoL method, ready to bind to a UnityEvent More...
 
virtual void SetVolumeUI (float newVolume)
 Sets the volume of the UI track to the specified value, QoL method, ready to bind to a UnityEvent More...
 
virtual void SetVolumeMaster (float newVolume)
 Sets the volume of the Master track to the specified value, QoL method, ready to bind to a UnityEvent More...
 
virtual bool IsMuted (MMSoundManagerTracks track)
 Returns true if the specified track is muted, false otherwise More...
 
virtual void FadeTrack (MMSoundManagerTracks track, float duration, float initialVolume=0f, float finalVolume=1f, MMTweenType tweenType=null)
 Fades an entire track over the specified duration towards the desired finalVolume More...
 
virtual void FadeSound (AudioSource source, float duration, float initialVolume, float finalVolume, MMTweenType tweenType, bool freeAfterFade=false)
 Fades a target sound towards a final volume over time More...
 
virtual bool SoundIsFadingIn (AudioSource source)
 Returns true if the specified source is already fading, false otherwise More...
 
virtual bool SoundIsFadingOut (AudioSource source)
 Returns true if the specified source is already fading, false otherwise More...
 
virtual void StopFadeTrack (MMSoundManagerTracks track)
 Stops any fade currently happening on the specified track More...
 
virtual void StopFadeSound (AudioSource source)
 Stops any fade currently happening on the specified sound More...
 
virtual void MuteSoundsOnTrack (MMSoundManagerTracks track, bool mute, float delay=0f)
 Mutes all sounds playing on a specific track More...
 
virtual void MuteAllSounds (bool mute=true)
 Mutes all sounds playing on the MMSoundManager More...
 
virtual AudioSource FindByID (int ID)
 Returns an audio source played with the specified ID, if one is found More...
 
virtual AudioSource FindByClip (AudioClip clip)
 Returns an audio source played with the specified ID, if one is found More...
 
virtual void PauseAllSounds ()
 Pauses all sounds playing on the MMSoundManager More...
 
virtual void PlayAllSounds ()
 Plays all sounds playing on the MMSoundManager More...
 
virtual void StopAllSounds ()
 Stops all sounds playing on the MMSoundManager More...
 
virtual void FreeAllSounds ()
 Stops all sounds and returns them to the pool More...
 
virtual void FreeAllSoundsButPersistent ()
 Stops all sounds except the persistent ones, and returns them to the pool More...
 
virtual void FreeAllLoopingSounds ()
 Stops all looping sounds and returns them to the pool More...
 
virtual void OnMMEvent (MMSoundManagerTrackEvent soundManagerTrackEvent)
 
virtual void OnMMEvent (MMSoundManagerEvent soundManagerEvent)
 
virtual void SaveSettings ()
 Save sound settings to file More...
 
virtual void LoadSettings ()
 Loads sound settings from file More...
 
virtual void ResetSettings ()
 Deletes any saved sound settings More...
 
virtual void OnMMEvent (MMSoundManagerSoundControlEvent soundControlEvent)
 
virtual void OnMMEvent (MMSoundManagerTrackFadeEvent trackFadeEvent)
 
virtual void OnMMEvent (MMSoundManagerSoundFadeEvent soundFadeEvent)
 
virtual void OnMMEvent (MMSoundManagerAllSoundsControlEvent allSoundsControlEvent)
 
virtual void OnMMSfxEvent (AudioClip clipToPlay, AudioMixerGroup audioGroup=null, float volume=1f, float pitch=1f, int priority=128)
 
virtual AudioSource OnMMSoundManagerSoundPlayEvent (AudioClip clip, MMSoundManagerPlayOptions options)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMSoundManagerTrackEvent >
void OnMMEvent (T eventType)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMSoundManagerEvent >
void OnMMEvent (T eventType)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMSoundManagerSoundControlEvent >
void OnMMEvent (T eventType)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMSoundManagerSoundFadeEvent >
void OnMMEvent (T eventType)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMSoundManagerAllSoundsControlEvent >
void OnMMEvent (T eventType)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMSoundManagerTrackFadeEvent >
void OnMMEvent (T eventType)
 

Public Attributes

MMSoundManagerSettingsSO settingsSo
 the current sound settings More...
 
int AudioSourcePoolSize = 10
 the size of the AudioSource pool, a reserve of ready-to-use sources that will get recycled. Should be approximately equal to the maximum amount of sounds that you expect to be playing at once More...
 
bool PoolCanExpand = true
 whether or not the pool can expand (create new audiosources on demand). In a perfect world you'd want to avoid this, and have a sufficiently big pool, to avoid costly runtime creations. More...
 
- Public Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< MMSoundManager >
bool AutomaticallyUnparentOnAwake
 if this is true, this singleton will auto detach if it finds itself parented on awake More...
 

Protected Member Functions

override void Awake ()
 On Awake we initialize our manager More...
 
virtual void Start ()
 On Start we load and apply our saved settings if needed. This is done on Start and not Awake because of a bug in Unity's AudioMixer API More...
 
virtual void InitializeSoundManager ()
 Initializes the pool, fills it, registers to the scene loaded event More...
 
virtual void ControlTrack (MMSoundManagerTracks track, ControlTrackModes trackMode, float volume=0.5f)
 
virtual IEnumerator FadeTrackCoroutine (MMSoundManagerTracks track, float duration, float initialVolume, float finalVolume, MMTweenType tweenType)
 Fades an entire track over time More...
 
virtual IEnumerator FadeCoroutine (AudioSource source, float duration, float initialVolume, float finalVolume, MMTweenType tweenType, bool freeAfterFade=false)
 Fades an audiosource's volume over time More...
 
virtual IEnumerator MuteSoundsOnTrackCoroutine (MMSoundManagerTracks track, bool mute, float delay)
 Mutes all sounds on the specified track after an optional delay More...
 
virtual IEnumerator MuteAllSoundsCoroutine (float delay, bool mute=true)
 Mutes all sounds after an optional delay More...
 
virtual void OnSceneLoaded (Scene arg0, LoadSceneMode loadSceneMode)
 Registered on enable, triggers every time a new scene is loaded At which point we free all sounds except the persistent ones More...
 
virtual void OnEnable ()
 On enable we start listening for events More...
 
virtual void OnDisable ()
 On disable we stop listening for events More...
 
- Protected Member Functions inherited from MoreMountains.Tools.MMPersistentSingleton< MMSoundManager >
virtual void InitializeSingleton ()
 Initializes the singleton. More...
 

Static Protected Member Functions

static void InitializeStatics ()
 Statics initialization to support enter play modes More...
 

Protected Attributes

MMSoundManagerAudioPool _pool
 
GameObject _tempAudioSourceGameObject
 
MMSoundManagerSound _sound
 
List< MMSoundManagerSound_sounds
 
AudioSource _tempAudioSource
 
Dictionary< AudioSource, Coroutine > _fadeInSoundCoroutines
 
Dictionary< AudioSource, Coroutine > _fadeOutSoundCoroutines
 
Dictionary< MMSoundManagerTracks, Coroutine > _fadeTrackCoroutines
 
- Protected Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< MMSoundManager >
bool _enabled
 

Additional Inherited Members

- Static Public Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< MMSoundManager >
static bool HasInstance
 
static T Current
 
- Static Protected Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< MMSoundManager >
static T _instance
 
- Properties inherited from MoreMountains.Tools.MMPersistentSingleton< MMSoundManager >
static T Instance [get]
 Singleton design pattern More...
 

Detailed Description

A simple yet powerful sound manager, that will let you play sounds with an event based approach and performance in mind.

Features :

  • Play/stop/pause/resume/free sounds
  • Full control : loop, volume, pitch, pan, spatial blend, bypasses, priority, reverb, doppler level, spread, rolloff mode, distance
  • 2D & 3D spatial support
  • Built-in pooling, automatically recycle a set of audio sources for maximum performance
  • Built in audio mixer and groups, with ready-made tracks (Master, Music, SFX, UI), and options to play on more groups if needed
  • Stop/pause/resume/free entire tracks
  • Stop/pause/resume/free all sounds at once
  • Mute / set volume entire tracks
  • Save and load settings, with auto save / auto load mechanics built-in
  • Fade in/out sounds
  • Fade in/out tracks
  • Solo mode : play a sound with one or all tracks muted, then unmute them automatically afterwards
  • PlayOptions struct
  • Option to have sounds persist across scene loads and from scene to scene
  • Inspector controls for tracks (volume, mute, unmute, play, pause, stop, resume, free, number of sounds)
  • MMSfxEvents
  • MMSoundManagerEvents : mute track, control track, save, load, reset, stop persistent sounds

Member Enumeration Documentation

◆ ControlTrackModes

A method that will let you mute/unmute a track, or set it to a specified volume

Enumerator
Mute 
Unmute 
SetVolume 

◆ MMSoundManagerTracks

the possible ways to manage a track

Enumerator
Sfx 
Music 
UI 
Master 
Other 

Member Function Documentation

◆ Awake()

override void MoreMountains.Tools.MMSoundManager.Awake ( )
protectedvirtual

On Awake we initialize our manager

Reimplemented from MoreMountains.Tools.MMPersistentSingleton< MMSoundManager >.

◆ ControlTrack()

virtual void MoreMountains.Tools.MMSoundManager.ControlTrack ( MMSoundManagerTracks  track,
ControlTrackModes  trackMode,
float  volume = 0.5f 
)
protectedvirtual

◆ FadeCoroutine()

virtual IEnumerator MoreMountains.Tools.MMSoundManager.FadeCoroutine ( AudioSource  source,
float  duration,
float  initialVolume,
float  finalVolume,
MMTweenType  tweenType,
bool  freeAfterFade = false 
)
protectedvirtual

Fades an audiosource's volume over time

Parameters
source
duration
initialVolume
finalVolume
tweenType
Returns

◆ FadeSound()

virtual void MoreMountains.Tools.MMSoundManager.FadeSound ( AudioSource  source,
float  duration,
float  initialVolume,
float  finalVolume,
MMTweenType  tweenType,
bool  freeAfterFade = false 
)
virtual

Fades a target sound towards a final volume over time

Parameters
source
duration
initialVolume
finalVolume
tweenType

◆ FadeTrack()

virtual void MoreMountains.Tools.MMSoundManager.FadeTrack ( MMSoundManagerTracks  track,
float  duration,
float  initialVolume = 0f,
float  finalVolume = 1f,
MMTweenType  tweenType = null 
)
virtual

Fades an entire track over the specified duration towards the desired finalVolume

Parameters
track
duration
initialVolume
finalVolume
tweenType

◆ FadeTrackCoroutine()

virtual IEnumerator MoreMountains.Tools.MMSoundManager.FadeTrackCoroutine ( MMSoundManagerTracks  track,
float  duration,
float  initialVolume,
float  finalVolume,
MMTweenType  tweenType 
)
protectedvirtual

Fades an entire track over time

Parameters
track
duration
initialVolume
finalVolume
tweenType
Returns

◆ FindByClip()

virtual AudioSource MoreMountains.Tools.MMSoundManager.FindByClip ( AudioClip  clip)
virtual

Returns an audio source played with the specified ID, if one is found

Parameters
ID
Returns

◆ FindByID()

virtual AudioSource MoreMountains.Tools.MMSoundManager.FindByID ( int  ID)
virtual

Returns an audio source played with the specified ID, if one is found

Parameters
ID
Returns

◆ FreeAllLoopingSounds()

virtual void MoreMountains.Tools.MMSoundManager.FreeAllLoopingSounds ( )
virtual

Stops all looping sounds and returns them to the pool

◆ FreeAllSounds()

virtual void MoreMountains.Tools.MMSoundManager.FreeAllSounds ( )
virtual

Stops all sounds and returns them to the pool

◆ FreeAllSoundsButPersistent()

virtual void MoreMountains.Tools.MMSoundManager.FreeAllSoundsButPersistent ( )
virtual

Stops all sounds except the persistent ones, and returns them to the pool

◆ FreeSound()

virtual void MoreMountains.Tools.MMSoundManager.FreeSound ( AudioSource  source)
virtual

Frees a specific sound, stopping it and returning it to the pool

Parameters
source

◆ FreeTrack()

virtual void MoreMountains.Tools.MMSoundManager.FreeTrack ( MMSoundManagerTracks  track)
virtual

Stops all sounds on a track, and returns them to the pool

Parameters
track

◆ GetSoundsPlaying()

virtual List<MMSoundManagerSound> MoreMountains.Tools.MMSoundManager.GetSoundsPlaying ( MMSoundManagerTracks  track)
virtual

Returns a list of MMSoundManagerSounds for the specified track

Parameters
trackthe track on which to grab the playing sounds
Returns

◆ GetTrackVolume()

virtual float MoreMountains.Tools.MMSoundManager.GetTrackVolume ( MMSoundManagerTracks  track,
bool  mutedVolume 
)
virtual

Returns the current volume of a track

Parameters
track
volume

◆ HasSoundsPlaying()

virtual bool MoreMountains.Tools.MMSoundManager.HasSoundsPlaying ( MMSoundManagerTracks  track)
virtual

Returns true if sounds are currently playing on that track

Parameters
track

◆ InitializeSoundManager()

virtual void MoreMountains.Tools.MMSoundManager.InitializeSoundManager ( )
protectedvirtual

Initializes the pool, fills it, registers to the scene loaded event

◆ InitializeStatics()

static void MoreMountains.Tools.MMSoundManager.InitializeStatics ( )
staticprotected

Statics initialization to support enter play modes

◆ IsMuted()

virtual bool MoreMountains.Tools.MMSoundManager.IsMuted ( MMSoundManagerTracks  track)
virtual

Returns true if the specified track is muted, false otherwise

Parameters
track
Returns

◆ LoadSettings()

virtual void MoreMountains.Tools.MMSoundManager.LoadSettings ( )
virtual

Loads sound settings from file

◆ MuteAllSounds()

virtual void MoreMountains.Tools.MMSoundManager.MuteAllSounds ( bool  mute = true)
virtual

Mutes all sounds playing on the MMSoundManager

Parameters
mute

◆ MuteAllSoundsCoroutine()

virtual IEnumerator MoreMountains.Tools.MMSoundManager.MuteAllSoundsCoroutine ( float  delay,
bool  mute = true 
)
protectedvirtual

Mutes all sounds after an optional delay

Parameters
delay
mute
Returns

◆ MuteMaster()

virtual void MoreMountains.Tools.MMSoundManager.MuteMaster ( )
virtual

Mutes the master track, QoL method ready to bind to a UnityEvent

◆ MuteMusic()

virtual void MoreMountains.Tools.MMSoundManager.MuteMusic ( )
virtual

Mutes the music track, QoL method ready to bind to a UnityEvent

◆ MuteSfx()

virtual void MoreMountains.Tools.MMSoundManager.MuteSfx ( )
virtual

Mutes the sfx track, QoL method ready to bind to a UnityEvent

◆ MuteSoundsOnTrack()

virtual void MoreMountains.Tools.MMSoundManager.MuteSoundsOnTrack ( MMSoundManagerTracks  track,
bool  mute,
float  delay = 0f 
)
virtual

Mutes all sounds playing on a specific track

Parameters
track
mute
delay

◆ MuteSoundsOnTrackCoroutine()

virtual IEnumerator MoreMountains.Tools.MMSoundManager.MuteSoundsOnTrackCoroutine ( MMSoundManagerTracks  track,
bool  mute,
float  delay 
)
protectedvirtual

Mutes all sounds on the specified track after an optional delay

Parameters
track
mute
delay
Returns

◆ MuteTrack()

virtual void MoreMountains.Tools.MMSoundManager.MuteTrack ( MMSoundManagerTracks  track)
virtual

Mutes an entire track

Parameters
track

◆ MuteUI()

virtual void MoreMountains.Tools.MMSoundManager.MuteUI ( )
virtual

Mutes the UI track, QoL method ready to bind to a UnityEvent

◆ OnDisable()

virtual void MoreMountains.Tools.MMSoundManager.OnDisable ( )
protectedvirtual

On disable we stop listening for events

◆ OnEnable()

virtual void MoreMountains.Tools.MMSoundManager.OnEnable ( )
protectedvirtual

On enable we start listening for events

◆ OnMMEvent() [1/6]

virtual void MoreMountains.Tools.MMSoundManager.OnMMEvent ( MMSoundManagerAllSoundsControlEvent  allSoundsControlEvent)
virtual

◆ OnMMEvent() [2/6]

virtual void MoreMountains.Tools.MMSoundManager.OnMMEvent ( MMSoundManagerEvent  soundManagerEvent)
virtual

◆ OnMMEvent() [3/6]

virtual void MoreMountains.Tools.MMSoundManager.OnMMEvent ( MMSoundManagerSoundControlEvent  soundControlEvent)
virtual

◆ OnMMEvent() [4/6]

virtual void MoreMountains.Tools.MMSoundManager.OnMMEvent ( MMSoundManagerSoundFadeEvent  soundFadeEvent)
virtual

◆ OnMMEvent() [5/6]

virtual void MoreMountains.Tools.MMSoundManager.OnMMEvent ( MMSoundManagerTrackEvent  soundManagerTrackEvent)
virtual

◆ OnMMEvent() [6/6]

virtual void MoreMountains.Tools.MMSoundManager.OnMMEvent ( MMSoundManagerTrackFadeEvent  trackFadeEvent)
virtual

◆ OnMMSfxEvent()

virtual void MoreMountains.Tools.MMSoundManager.OnMMSfxEvent ( AudioClip  clipToPlay,
AudioMixerGroup  audioGroup = null,
float  volume = 1f,
float  pitch = 1f,
int  priority = 128 
)
virtual

◆ OnMMSoundManagerSoundPlayEvent()

virtual AudioSource MoreMountains.Tools.MMSoundManager.OnMMSoundManagerSoundPlayEvent ( AudioClip  clip,
MMSoundManagerPlayOptions  options 
)
virtual

◆ OnSceneLoaded()

virtual void MoreMountains.Tools.MMSoundManager.OnSceneLoaded ( Scene  arg0,
LoadSceneMode  loadSceneMode 
)
protectedvirtual

Registered on enable, triggers every time a new scene is loaded At which point we free all sounds except the persistent ones

◆ PauseAllSounds()

virtual void MoreMountains.Tools.MMSoundManager.PauseAllSounds ( )
virtual

Pauses all sounds playing on the MMSoundManager

◆ PauseSound()

virtual void MoreMountains.Tools.MMSoundManager.PauseSound ( AudioSource  source)
virtual

Pauses the specified audiosource

Parameters
source

◆ PauseTrack()

virtual void MoreMountains.Tools.MMSoundManager.PauseTrack ( MMSoundManagerTracks  track)
virtual

Pauses all sounds on a track

Parameters
track

◆ PlayAllSounds()

virtual void MoreMountains.Tools.MMSoundManager.PlayAllSounds ( )
virtual

Plays all sounds playing on the MMSoundManager

◆ PlaySound() [1/2]

virtual AudioSource MoreMountains.Tools.MMSoundManager.PlaySound ( AudioClip  audioClip,
MMSoundManagerPlayOptions  options 
)
virtual

Plays a sound, separate options object signature

Parameters
audioClip
options
Returns

◆ PlaySound() [2/2]

virtual AudioSource MoreMountains.Tools.MMSoundManager.PlaySound ( AudioClip  audioClip,
MMSoundManagerTracks  mmSoundManagerTrack,
Vector3  location,
bool  loop = false,
float  volume = 1.0f,
int  ID = 0,
bool  fade = false,
float  fadeInitialVolume = 0f,
float  fadeDuration = 1f,
MMTweenType  fadeTween = null,
bool  persistent = false,
AudioSource  recycleAudioSource = null,
AudioMixerGroup  audioGroup = null,
float  pitch = 1f,
float  panStereo = 0f,
float  spatialBlend = 0.0f,
bool  soloSingleTrack = false,
bool  soloAllTracks = false,
bool  autoUnSoloOnEnd = false,
bool  bypassEffects = false,
bool  bypassListenerEffects = false,
bool  bypassReverbZones = false,
int  priority = 128,
float  reverbZoneMix = 1f,
float  dopplerLevel = 1f,
int  spread = 0,
AudioRolloffMode  rolloffMode = AudioRolloffMode.Logarithmic,
float  minDistance = 1f,
float  maxDistance = 500f,
bool  doNotAutoRecycleIfNotDonePlaying = false,
float  playbackTime = 0f,
float  playbackDuration = 0f,
Transform  attachToTransform = null,
bool  useSpreadCurve = false,
AnimationCurve  spreadCurve = null,
bool  useCustomRolloffCurve = false,
AnimationCurve  customRolloffCurve = null,
bool  useSpatialBlendCurve = false,
AnimationCurve  spatialBlendCurve = null,
bool  useReverbZoneMixCurve = false,
AnimationCurve  reverbZoneMixCurve = null 
)
virtual

Plays a sound, signature with all options

Parameters
audioClip
mmSoundManagerTrack
location
loop
volume
ID
fade
fadeInitialVolume
fadeDuration
fadeTween
persistent
recycleAudioSource
audioGroup
pitch
panStereo
spatialBlend
soloSingleTrack
soloAllTracks
autoUnSoloOnEnd
bypassEffects
bypassListenerEffects
bypassReverbZones
priority
reverbZoneMix
dopplerLevel
spread
rolloffMode
minDistance
maxDistance
Returns

◆ PlayTrack()

virtual void MoreMountains.Tools.MMSoundManager.PlayTrack ( MMSoundManagerTracks  track)
virtual

Plays or resumes all sounds on a track

Parameters
track

◆ ResetSettings()

virtual void MoreMountains.Tools.MMSoundManager.ResetSettings ( )
virtual

Deletes any saved sound settings

◆ ResumeSound()

virtual void MoreMountains.Tools.MMSoundManager.ResumeSound ( AudioSource  source)
virtual

resumes play on the specified audio source

Parameters
source

◆ SaveSettings()

virtual void MoreMountains.Tools.MMSoundManager.SaveSettings ( )
virtual

Save sound settings to file

◆ SetTrackVolume()

virtual void MoreMountains.Tools.MMSoundManager.SetTrackVolume ( MMSoundManagerTracks  track,
float  volume 
)
virtual

Sets the volume of an entire track

Parameters
track
volume

◆ SetVolumeMaster()

virtual void MoreMountains.Tools.MMSoundManager.SetVolumeMaster ( float  newVolume)
virtual

Sets the volume of the Master track to the specified value, QoL method, ready to bind to a UnityEvent

◆ SetVolumeMusic()

virtual void MoreMountains.Tools.MMSoundManager.SetVolumeMusic ( float  newVolume)
virtual

Sets the volume of the Music track to the specified value, QoL method, ready to bind to a UnityEvent

◆ SetVolumeSfx()

virtual void MoreMountains.Tools.MMSoundManager.SetVolumeSfx ( float  newVolume)
virtual

Sets the volume of the SFX track to the specified value, QoL method, ready to bind to a UnityEvent

◆ SetVolumeUI()

virtual void MoreMountains.Tools.MMSoundManager.SetVolumeUI ( float  newVolume)
virtual

Sets the volume of the UI track to the specified value, QoL method, ready to bind to a UnityEvent

◆ SoundIsFadingIn()

virtual bool MoreMountains.Tools.MMSoundManager.SoundIsFadingIn ( AudioSource  source)
virtual

Returns true if the specified source is already fading, false otherwise

Parameters
source
Returns

◆ SoundIsFadingOut()

virtual bool MoreMountains.Tools.MMSoundManager.SoundIsFadingOut ( AudioSource  source)
virtual

Returns true if the specified source is already fading, false otherwise

Parameters
source
Returns

◆ Start()

virtual void MoreMountains.Tools.MMSoundManager.Start ( )
protectedvirtual

On Start we load and apply our saved settings if needed. This is done on Start and not Awake because of a bug in Unity's AudioMixer API

◆ StopAllSounds()

virtual void MoreMountains.Tools.MMSoundManager.StopAllSounds ( )
virtual

Stops all sounds playing on the MMSoundManager

◆ StopFadeSound()

virtual void MoreMountains.Tools.MMSoundManager.StopFadeSound ( AudioSource  source)
virtual

Stops any fade currently happening on the specified sound

Parameters
source

◆ StopFadeTrack()

virtual void MoreMountains.Tools.MMSoundManager.StopFadeTrack ( MMSoundManagerTracks  track)
virtual

Stops any fade currently happening on the specified track

Parameters
track

◆ StopSound()

virtual void MoreMountains.Tools.MMSoundManager.StopSound ( AudioSource  source)
virtual

Stops the specified audio source

Parameters
source

◆ StopTrack()

virtual void MoreMountains.Tools.MMSoundManager.StopTrack ( MMSoundManagerTracks  track)
virtual

Stops all sounds on a track

Parameters
track

◆ UnmuteMaster()

virtual void MoreMountains.Tools.MMSoundManager.UnmuteMaster ( )
virtual

Unmutes the master track, QoL method ready to bind to a UnityEvent

◆ UnmuteMusic()

virtual void MoreMountains.Tools.MMSoundManager.UnmuteMusic ( )
virtual

Unmutes the music track, QoL method ready to bind to a UnityEvent

◆ UnmuteSfx()

virtual void MoreMountains.Tools.MMSoundManager.UnmuteSfx ( )
virtual

Unmutes the sfx track, QoL method ready to bind to a UnityEvent

◆ UnmuteTrack()

virtual void MoreMountains.Tools.MMSoundManager.UnmuteTrack ( MMSoundManagerTracks  track)
virtual

Unmutes an entire track

Parameters
track

◆ UnmuteUI()

virtual void MoreMountains.Tools.MMSoundManager.UnmuteUI ( )
virtual

Unmutes the UI track, QoL method ready to bind to a UnityEvent

Member Data Documentation

◆ _fadeInSoundCoroutines

Dictionary<AudioSource, Coroutine> MoreMountains.Tools.MMSoundManager._fadeInSoundCoroutines
protected

◆ _fadeOutSoundCoroutines

Dictionary<AudioSource, Coroutine> MoreMountains.Tools.MMSoundManager._fadeOutSoundCoroutines
protected

◆ _fadeTrackCoroutines

Dictionary<MMSoundManagerTracks, Coroutine> MoreMountains.Tools.MMSoundManager._fadeTrackCoroutines
protected

◆ _pool

MMSoundManagerAudioPool MoreMountains.Tools.MMSoundManager._pool
protected

◆ _sound

MMSoundManagerSound MoreMountains.Tools.MMSoundManager._sound
protected

◆ _sounds

List<MMSoundManagerSound> MoreMountains.Tools.MMSoundManager._sounds
protected

◆ _tempAudioSource

AudioSource MoreMountains.Tools.MMSoundManager._tempAudioSource
protected

◆ _tempAudioSourceGameObject

GameObject MoreMountains.Tools.MMSoundManager._tempAudioSourceGameObject
protected

◆ AudioSourcePoolSize

int MoreMountains.Tools.MMSoundManager.AudioSourcePoolSize = 10

the size of the AudioSource pool, a reserve of ready-to-use sources that will get recycled. Should be approximately equal to the maximum amount of sounds that you expect to be playing at once

◆ PoolCanExpand

bool MoreMountains.Tools.MMSoundManager.PoolCanExpand = true

whether or not the pool can expand (create new audiosources on demand). In a perfect world you'd want to avoid this, and have a sufficiently big pool, to avoid costly runtime creations.

◆ settingsSo

MMSoundManagerSettingsSO MoreMountains.Tools.MMSoundManager.settingsSo

the current sound settings


The documentation for this class was generated from the following file: