![]() |
Highroad Engine v1.3
|
A simple yet powerful sound manager, that will let you play sounds with an event based approach and performance in mind. More...
Public Types | |
enum | MMSoundManagerTracks { Sfx , Music , UI , Master , Other } |
the possible ways to manage a track More... | |
enum | ControlTrackModes { Mute , Unmute , 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) |
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 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) |
Fades a target sound towards a final volume over time 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 () |
Pauses 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) |
virtual AudioSource | OnMMSoundManagerSoundPlayEvent (AudioClip clip, MMSoundManagerPlayOptions options) |
![]() | |
void | OnMMEvent (T eventType) |
![]() | |
void | OnMMEvent (T eventType) |
![]() | |
void | OnMMEvent (T eventType) |
![]() | |
void | OnMMEvent (T eventType) |
![]() | |
void | OnMMEvent (T eventType) |
![]() | |
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... | |
![]() | |
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) |
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 Attributes | |
MMSoundManagerAudioPool | _pool |
GameObject | _tempAudioSourceGameObject |
MMSoundManagerSound | _sound |
List< MMSoundManagerSound > | _sounds |
AudioSource | _tempAudioSource |
![]() | |
bool | _enabled |
Additional Inherited Members | |
![]() | |
static T | _instance |
![]() | |
static bool | HasInstance [get] |
static T | Current [get] |
static T | Instance [get] |
Singleton design pattern More... | |
A simple yet powerful sound manager, that will let you play sounds with an event based approach and performance in mind.
Features :
|
protectedvirtual |
On Awake we initialize our manager
Reimplemented from MoreMountains.Tools.MMPersistentSingleton< MMSoundManager >.
|
protectedvirtual |
|
protectedvirtual |
Fades an audiosource's volume over time
source | |
duration | |
initialVolume | |
finalVolume | |
tweenType |
|
virtual |
Fades a target sound towards a final volume over time
source | |
duration | |
initialVolume | |
finalVolume | |
tweenType |
|
virtual |
Fades an entire track over the specified duration towards the desired finalVolume
track | |
duration | |
initialVolume | |
finalVolume | |
tweenType |
|
protectedvirtual |
Fades an entire track over time
track | |
duration | |
initialVolume | |
finalVolume | |
tweenType |
|
virtual |
Returns an audio source played with the specified ID, if one is found
ID |
|
virtual |
Returns an audio source played with the specified ID, if one is found
ID |
|
virtual |
Stops all looping sounds and returns them to the pool
|
virtual |
Stops all sounds and returns them to the pool
|
virtual |
Stops all sounds except the persistent ones, and returns them to the pool
|
virtual |
Frees a specific sound, stopping it and returning it to the pool
source |
|
virtual |
Stops all sounds on a track, and returns them to the pool
track |
|
virtual |
Returns the current volume of a track
track | |
volume |
|
virtual |
Returns true if sounds are currently playing on that track
track |
|
protectedvirtual |
Initializes the pool, fills it, registers to the scene loaded event
|
virtual |
Returns true if the specified track is muted, false otherwise
track |
|
virtual |
Loads sound settings from file
|
virtual |
Mutes all sounds playing on the MMSoundManager
mute |
|
protectedvirtual |
Mutes all sounds after an optional delay
delay | |
mute |
|
virtual |
Mutes the master track, QoL method ready to bind to a UnityEvent
|
virtual |
Mutes the music track, QoL method ready to bind to a UnityEvent
|
virtual |
Mutes the sfx track, QoL method ready to bind to a UnityEvent
|
virtual |
Mutes all sounds playing on a specific track
track | |
mute | |
delay |
|
protectedvirtual |
Mutes all sounds on the specified track after an optional delay
track | |
mute | |
delay |
|
virtual |
Mutes an entire track
track |
|
virtual |
Mutes the UI track, QoL method ready to bind to a UnityEvent
|
protectedvirtual |
On disable we stop listening for events
|
protectedvirtual |
On enable we start listening for events
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
protectedvirtual |
Registered on enable, triggers every time a new scene is loaded At which point we free all sounds except the persistent ones
|
virtual |
Pauses all sounds playing on the MMSoundManager
|
virtual |
Pauses the specified audiosource
source |
|
virtual |
Pauses all sounds on a track
track |
|
virtual |
Pauses all sounds playing on the MMSoundManager
|
virtual |
Plays a sound, separate options object signature
audioClip | |
options |
|
virtual |
Plays a sound, signature with all options
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 |
|
virtual |
Plays or resumes all sounds on a track
track |
|
virtual |
Deletes any saved sound settings
|
virtual |
resumes play on the specified audio source
source |
|
virtual |
Save sound settings to file
|
virtual |
Sets the volume of an entire track
track | |
volume |
|
virtual |
Sets the volume of the Master track to the specified value, QoL method, ready to bind to a UnityEvent
|
virtual |
Sets the volume of the Music track to the specified value, QoL method, ready to bind to a UnityEvent
|
virtual |
Sets the volume of the SFX track to the specified value, QoL method, ready to bind to a UnityEvent
|
virtual |
Sets the volume of the UI track to the specified value, QoL method, ready to bind to a UnityEvent
|
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
|
virtual |
Stops all sounds playing on the MMSoundManager
|
virtual |
Stops the specified audio source
source |
|
virtual |
Stops all sounds on a track
track |
|
virtual |
Unmutes the master track, QoL method ready to bind to a UnityEvent
|
virtual |
Unmutes the music track, QoL method ready to bind to a UnityEvent
|
virtual |
Unmutes the sfx track, QoL method ready to bind to a UnityEvent
|
virtual |
Unmutes an entire track
track |
|
virtual |
Unmutes the UI track, QoL method ready to bind to a UnityEvent
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
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
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.
MMSoundManagerSettingsSO MoreMountains.Tools.MMSoundManager.settingsSo |
the current sound settings