Corgi Engine  v8.8
MoreMountains.CorgiEngine.SoundManager Class Reference

This persistent singleton handles sound playing More...

Inheritance diagram for MoreMountains.CorgiEngine.SoundManager:
MoreMountains.Tools.MMPersistentSingleton< SoundManager > MoreMountains.Tools.MMEventListener< CorgiEngineEvent > MoreMountains.Tools.MMEventListener< MMGameEvent >

Public Member Functions

virtual void PlayBackgroundMusic (AudioSource Music)
 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)
 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 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...
 
virtual void OnMMEvent (CorgiEngineEvent engineEvent)
 Watches for pause events to cut the sound on pause More...
 
virtual void UnmuteBackgroundMusic ()
 Unmutes the background music More...
 
virtual void MuteBackgroundMusic ()
 Mutes the background music More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< CorgiEngineEvent >
void OnMMEvent (T eventType)
 
- Public Member Functions inherited from MoreMountains.Tools.MMEventListener< MMGameEvent >
void OnMMEvent (T eventType)
 

Public Attributes

SoundSettings Settings
 the sound settings to use for this manager More...
 
float MusicVolume =0.3f
 the music volume More...
 
float SfxVolume =1f
 the sound fx volume More...
 
bool MuteSfxOnPause = true
 whether or not to mute sfx when pausing the game 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...
 

Static Protected Member Functions

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

Protected Attributes

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

Static Protected Attributes

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

Additional Inherited Members

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

Detailed Description

This persistent singleton handles sound playing

Member Function Documentation

◆ InitializeStatics()

static void MoreMountains.CorgiEngine.SoundManager.InitializeStatics ( )
staticprotected

Statics initialization to support enter play modes

◆ LoadSoundSettings()

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

Loads the sound settings from file (if found)

◆ MusicOff()

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

Sets the Music setting to Off

◆ MusicOn()

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

Sets the music setting to On

◆ MuteAllSfx()

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

Mutes all sfx currently playing

◆ MuteBackgroundMusic()

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

Mutes the background music

◆ OnDisable()

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

On disable we stop listening for events

◆ OnEnable()

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

On enable we start listening for events

◆ OnMMEvent() [1/2]

virtual void MoreMountains.CorgiEngine.SoundManager.OnMMEvent ( CorgiEngineEvent  engineEvent)
virtual

Watches for pause events to cut the sound on pause

Parameters
engineEvent

◆ OnMMEvent() [2/2]

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

Watches for game events to mute sfx if needed

Parameters
gameEvent

◆ OnMMSfxEvent()

virtual void MoreMountains.CorgiEngine.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

◆ PlayBackgroundMusic()

virtual void MoreMountains.CorgiEngine.SoundManager.PlayBackgroundMusic ( AudioSource  Music)
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.CorgiEngine.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.CorgiEngine.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 
)
virtual

Advanced PlaySound method

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

◆ ResetSoundSettings()

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

Resets the sound settings by destroying the save file

◆ SaveSoundSettings()

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

Saves the sound settings to file

◆ SetMusic()

virtual void MoreMountains.CorgiEngine.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.CorgiEngine.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.CorgiEngine.SoundManager.SfxOff ( )
virtual

Sets the SFX setting to Off

◆ SfxOn()

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

Sets the SFX setting to On

◆ StopLoopingSound()

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

Stops the looping sounds if there are any

Parameters
sourceSource.

◆ UnmuteAllSfx()

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

Unmutes all sfx currently playing

◆ UnmuteBackgroundMusic()

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

Unmutes the background music

Member Data Documentation

◆ _backgroundMusic

AudioSource MoreMountains.CorgiEngine.SoundManager._backgroundMusic
protected

◆ _loopingSounds

List<AudioSource> MoreMountains.CorgiEngine.SoundManager._loopingSounds
protected

◆ _saveFileName

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

◆ _saveFolderName

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

◆ MusicVolume

float MoreMountains.CorgiEngine.SoundManager.MusicVolume =0.3f

the music volume

◆ MuteSfxOnPause

bool MoreMountains.CorgiEngine.SoundManager.MuteSfxOnPause = true

whether or not to mute sfx when pausing the game

◆ Settings

SoundSettings MoreMountains.CorgiEngine.SoundManager.Settings

the sound settings to use for this manager

◆ SfxVolume

float MoreMountains.CorgiEngine.SoundManager.SfxVolume =1f

the sound fx volume


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