TopDown Engine  v3.6
MoreMountains.TopDownEngine.SoundManager Class Reference

This persistent singleton handles sound playing More...

Inheritance diagram for MoreMountains.TopDownEngine.SoundManager:
MoreMountains.Tools.MMPersistentSingleton< SoundManager > MoreMountains.Tools.MMEventListener< TopDownEngineEvent > MoreMountains.Tools.MMEventListener< MMGameEvent >

Public Member Functions

virtual void PlayBackgroundMusic (AudioSource musicAudioSource, bool loop=true)
 Plays a background music. Only one background music can be active at a time. More...
 
virtual AudioSource PlaySound (AudioClip sfx, Vector3 location, bool loop=false)
 Plays a sound More...
 
virtual AudioSource PlaySound (AudioClip sfx, Vector3 location, float pitch, float pan, float spatialBlend=0.0f, float volumeMultiplier=1.0f, bool loop=false, AudioSource reuseSource=null, AudioMixerGroup audioGroup=null, int priority=128)
 Advanced PlaySound method More...
 
virtual void StopLoopingSound (AudioSource source)
 Stops the looping sounds if there are any More...
 
virtual void MusicOn ()
 Sets the music setting to On More...
 
virtual void MusicOff ()
 Sets the Music setting to Off More...
 
virtual void SfxOn ()
 Sets the SFX setting to On More...
 
virtual void SfxOff ()
 Sets the SFX setting to Off More...
 
virtual void StopAllLoopingSounds ()
 Stops all currently looping sounds More...
 
virtual void UnmuteBackgroundMusic ()
 Unmutes the background music More...
 
virtual void MuteBackgroundMusic ()
 Mutes the background music More...
 
bool IsBackgroundMusicInScene ()
 
bool IsBackgroundMusicPlaying ()
 
virtual void PauseBackgroundMusic ()
 
virtual void ResumeBackgroundMusic ()
 
virtual void StopBackgroundMusic ()
 
virtual void OnMMEvent (TopDownEngineEvent engineEvent)
 Watches for pause events to cut the sound on pause More...
 
virtual void OnMMSfxEvent (AudioClip clipToPlay, AudioMixerGroup audioGroup=null, float volume=1f, float pitch=1f, int priority=128)
 When we grab a sfx event, we play the corresponding sound More...
 
virtual void OnMMEvent (MMGameEvent gameEvent)
 Watches for game events to mute sfx if needed More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< TopDownEngineEvent >
void OnMMEvent (T eventType)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMGameEvent >
void OnMMEvent (T eventType)
 

Public Attributes

SoundSettings Settings
 the current sound settings More...
 
float MusicVolume = 0.3f
 the music volume More...
 
float SfxVolume = 1f
 the sound fx volume More...
 
bool MuteSfxOnPause = true
 whether or not Sfx should be muted when the game is paused More...
 
- Public Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< SoundManager >
bool AutomaticallyUnparentOnAwake
 if this is true, this singleton will auto detach if it finds itself parented on awake More...
 

Protected Member Functions

virtual void SetMusic (bool status)
 Sets the music on/off setting based on the value in parameters This value will be saved, and any music played after that setting change will comply More...
 
virtual void SetSfx (bool status)
 Sets the SFX on/off setting based on the value in parameters This value will be saved, and any SFX played after that setting change will comply More...
 
virtual void SaveSoundSettings ()
 Saves the sound settings to file More...
 
virtual void LoadSoundSettings ()
 Loads the sound settings from file (if found) More...
 
virtual void ResetSoundSettings ()
 Resets the sound settings by destroying the save file More...
 
virtual void MuteAllSfx ()
 Mutes all sfx currently playing More...
 
virtual void UnmuteAllSfx ()
 Unmutes all sfx currently playing 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< SoundManager >
virtual void Awake ()
 On awake, we check if there's already a copy of the object in the scene. If there's one, we destroy it. More...
 
virtual void InitializeSingleton ()
 Initializes the singleton. More...
 

Protected Attributes

AudioSource _backgroundMusic
 
List< AudioSource > _loopingSounds = new List<AudioSource>()
 
- Protected Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< SoundManager >
bool _enabled
 

Static Protected Attributes

const string _saveFolderName = "TopDownEngine/"
 
const string _saveFileName = "sound.settings"
 
- Static Protected Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< SoundManager >
static T _instance
 

Properties

virtual bool IsMusicOn [get, set]
 
virtual bool IsSfxOn [get, set]
 
- Properties inherited from MoreMountains.Tools.MMPersistentSingleton< SoundManager >
static T Instance [get]
 Singleton design pattern More...
 

Additional Inherited Members

- Static Public Attributes inherited from MoreMountains.Tools.MMPersistentSingleton< SoundManager >
static bool HasInstance
 
static T Current
 

Detailed Description

This persistent singleton handles sound playing

Member Function Documentation

◆ IsBackgroundMusicInScene()

bool MoreMountains.TopDownEngine.SoundManager.IsBackgroundMusicInScene ( )

◆ IsBackgroundMusicPlaying()

bool MoreMountains.TopDownEngine.SoundManager.IsBackgroundMusicPlaying ( )

◆ LoadSoundSettings()

virtual void MoreMountains.TopDownEngine.SoundManager.LoadSoundSettings ( )
protectedvirtual

Loads the sound settings from file (if found)

◆ MusicOff()

virtual void MoreMountains.TopDownEngine.SoundManager.MusicOff ( )
virtual

Sets the Music setting to Off

◆ MusicOn()

virtual void MoreMountains.TopDownEngine.SoundManager.MusicOn ( )
virtual

Sets the music setting to On

◆ MuteAllSfx()

virtual void MoreMountains.TopDownEngine.SoundManager.MuteAllSfx ( )
protectedvirtual

Mutes all sfx currently playing

◆ MuteBackgroundMusic()

virtual void MoreMountains.TopDownEngine.SoundManager.MuteBackgroundMusic ( )
virtual

Mutes the background music

◆ OnDisable()

virtual void MoreMountains.TopDownEngine.SoundManager.OnDisable ( )
protectedvirtual

On disable we stop listening for events

◆ OnEnable()

virtual void MoreMountains.TopDownEngine.SoundManager.OnEnable ( )
protectedvirtual

On enable we start listening for events

◆ OnMMEvent() [1/2]

virtual void MoreMountains.TopDownEngine.SoundManager.OnMMEvent ( MMGameEvent  gameEvent)
virtual

Watches for game events to mute sfx if needed

Parameters
gameEvent

◆ OnMMEvent() [2/2]

virtual void MoreMountains.TopDownEngine.SoundManager.OnMMEvent ( TopDownEngineEvent  engineEvent)
virtual

Watches for pause events to cut the sound on pause

Parameters
engineEvent

◆ OnMMSfxEvent()

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

When we grab a sfx event, we play the corresponding sound

Parameters
sfxEvent

◆ PauseBackgroundMusic()

virtual void MoreMountains.TopDownEngine.SoundManager.PauseBackgroundMusic ( )
virtual

◆ PlayBackgroundMusic()

virtual void MoreMountains.TopDownEngine.SoundManager.PlayBackgroundMusic ( AudioSource  musicAudioSource,
bool  loop = true 
)
virtual

Plays a background music. Only one background music can be active at a time.

Parameters
ClipYour audio clip.

◆ PlaySound() [1/2]

virtual AudioSource MoreMountains.TopDownEngine.SoundManager.PlaySound ( AudioClip  sfx,
Vector3  location,
bool  loop = false 
)
virtual

Plays a sound

Returns
An audiosource
Parameters
sfxThe sound clip you want to play.
locationThe location of the sound.
loopIf set to true, the sound will loop.

◆ PlaySound() [2/2]

virtual AudioSource MoreMountains.TopDownEngine.SoundManager.PlaySound ( AudioClip  sfx,
Vector3  location,
float  pitch,
float  pan,
float  spatialBlend = 0.0f,
float  volumeMultiplier = 1.0f,
bool  loop = false,
AudioSource  reuseSource = null,
AudioMixerGroup  audioGroup = null,
int  priority = 128 
)
virtual

Advanced PlaySound method

Parameters
sfx
location
pitch
pan
spatialBlend
volumeMultiplier
loop
reuseSource
audioGroup
soundFadeInDuration
Returns

◆ ResetSoundSettings()

virtual void MoreMountains.TopDownEngine.SoundManager.ResetSoundSettings ( )
protectedvirtual

Resets the sound settings by destroying the save file

◆ ResumeBackgroundMusic()

virtual void MoreMountains.TopDownEngine.SoundManager.ResumeBackgroundMusic ( )
virtual

◆ SaveSoundSettings()

virtual void MoreMountains.TopDownEngine.SoundManager.SaveSoundSettings ( )
protectedvirtual

Saves the sound settings to file

◆ SetMusic()

virtual void MoreMountains.TopDownEngine.SoundManager.SetMusic ( bool  status)
protectedvirtual

Sets the music on/off setting based on the value in parameters This value will be saved, and any music played after that setting change will comply

Parameters
status

◆ SetSfx()

virtual void MoreMountains.TopDownEngine.SoundManager.SetSfx ( bool  status)
protectedvirtual

Sets the SFX on/off setting based on the value in parameters This value will be saved, and any SFX played after that setting change will comply

Parameters
status

◆ SfxOff()

virtual void MoreMountains.TopDownEngine.SoundManager.SfxOff ( )
virtual

Sets the SFX setting to Off

◆ SfxOn()

virtual void MoreMountains.TopDownEngine.SoundManager.SfxOn ( )
virtual

Sets the SFX setting to On

◆ StopAllLoopingSounds()

virtual void MoreMountains.TopDownEngine.SoundManager.StopAllLoopingSounds ( )
virtual

Stops all currently looping sounds

◆ StopBackgroundMusic()

virtual void MoreMountains.TopDownEngine.SoundManager.StopBackgroundMusic ( )
virtual

◆ StopLoopingSound()

virtual void MoreMountains.TopDownEngine.SoundManager.StopLoopingSound ( AudioSource  source)
virtual

Stops the looping sounds if there are any

Parameters
sourceSource.

◆ UnmuteAllSfx()

virtual void MoreMountains.TopDownEngine.SoundManager.UnmuteAllSfx ( )
protectedvirtual

Unmutes all sfx currently playing

◆ UnmuteBackgroundMusic()

virtual void MoreMountains.TopDownEngine.SoundManager.UnmuteBackgroundMusic ( )
virtual

Unmutes the background music

Member Data Documentation

◆ _backgroundMusic

AudioSource MoreMountains.TopDownEngine.SoundManager._backgroundMusic
protected

◆ _loopingSounds

List<AudioSource> MoreMountains.TopDownEngine.SoundManager._loopingSounds = new List<AudioSource>()
protected

◆ _saveFileName

const string MoreMountains.TopDownEngine.SoundManager._saveFileName = "sound.settings"
staticprotected

◆ _saveFolderName

const string MoreMountains.TopDownEngine.SoundManager._saveFolderName = "TopDownEngine/"
staticprotected

◆ MusicVolume

float MoreMountains.TopDownEngine.SoundManager.MusicVolume = 0.3f

the music volume

◆ MuteSfxOnPause

bool MoreMountains.TopDownEngine.SoundManager.MuteSfxOnPause = true

whether or not Sfx should be muted when the game is paused

◆ Settings

SoundSettings MoreMountains.TopDownEngine.SoundManager.Settings

the current sound settings

◆ SfxVolume

float MoreMountains.TopDownEngine.SoundManager.SfxVolume = 1f

the sound fx volume

Property Documentation

◆ IsMusicOn

virtual bool MoreMountains.TopDownEngine.SoundManager.IsMusicOn
getset

◆ IsSfxOn

virtual bool MoreMountains.TopDownEngine.SoundManager.IsSfxOn
getset

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