AudioManager  1.3.0
A simple way for programmers to manage and control their 2D game’s background music and sound effects
Papae.UnitySDK.Managers.AudioManager Class Reference

The manager of all things with regards to sound More...

Inheritance diagram for Papae.UnitySDK.Managers.AudioManager:

Public Member Functions

void PlayBGM (AudioClip clip, MusicTransition transition, float transition_duration, float volume, float pitch, float playback_position=0)
 Plays a background music. More...
 
void PlayBGM (AudioClip clip, MusicTransition transition, float transition_duration, float volume)
 Plays a background music. More...
 
void PlayBGM (AudioClip clip, MusicTransition transition, float transition_duration)
 Plays a background music. More...
 
void PlayBGM (AudioClip clip, MusicTransition transition)
 Plays a background music. More...
 
void PlayBGM (AudioClip clip)
 Plays a background music using the swift the transition mode. More...
 
void PlayBGM (string clip_path, MusicTransition transition, float transition_duration, float volume, float pitch, float playback_position=0)
 Plays a background music. More...
 
void PlayBGM (string clip_path, MusicTransition transition, float transition_duration, float volume)
 Plays a background music. More...
 
void PlayBGM (string clip_path, MusicTransition transition, float transition_duration)
 Plays a background music. More...
 
void PlayBGM (string clip_path, MusicTransition transition)
 Plays a background music. More...
 
void PlayBGM (string clip_path)
 Plays a background music using the swift the transition mode. More...
 
void StopBGM ()
 Stops the playing background music More...
 
void PauseBGM ()
 Pauses the playing background music More...
 
void ResumeBGM ()
 Resumes the playing background music More...
 
int IndexOfSoundFxPool (string name, bool singleton=false)
 Returns the index of a sound effect in pool if one exists. More...
 
AudioSource PlaySFX (AudioClip clip, Vector2 location, float duration, float volume, bool singleton=false, float pitch=1f, Action callback=null)
 Plays a sound effect for a duration of time at a given location in world space and calls the specified callback function after the time is over. More...
 
AudioSource PlaySFX (AudioClip clip, Vector2 location, float duration, bool singleton=false, Action callback=null)
 Plays a sound effect for a duration of time at a given location in world space and calls the specified callback function after the time is over More...
 
AudioSource PlaySFX (AudioClip clip, float duration, bool singleton=false, Action callback=null)
 Plays a sound effect for a duration of time and calls the specified callback function after the time is over More...
 
AudioSource RepeatSFX (AudioClip clip, Vector2 location, int repeat, float volume, bool singleton=false, float pitch=1f, Action callback=null)
 Repeats a sound effect for a specified amount of times at a given location in world space and calls the specified callback function after the sound is over. More...
 
AudioSource RepeatSFX (AudioClip clip, Vector2 location, int repeat, bool singleton=false, Action callback=null)
 Repeats a sound effect for a specified amount of times at a given location in world space and calls the specified callback function after the sound is over. More...
 
AudioSource RepeatSFX (AudioClip clip, int repeat, bool singleton=false, Action callback=null)
 Repeats a sound effect for a specified amount of times at a given location in world space and calls the specified callback function after the sound is over. More...
 
AudioSource PlayOneShot (AudioClip clip, Vector2 location, float volume, float pitch=1f, Action callback=null)
 Plays a sound effect once at a location in world space and calls the specified callback function after the sound is over More...
 
AudioSource PlayOneShot (AudioClip clip, Vector2 location, Action callback=null)
 Plays a sound effect once at a location in world space More...
 
AudioSource PlayOneShot (AudioClip clip, Action callback=null)
 Plays a sound effect once and calls the specified callback function after the sound is over More...
 
void PauseAllSFX ()
 Pauses all the sound effects in the game More...
 
void ResumeAllSFX ()
 Resumes all the sound effect in the game More...
 
void StopAllSFX ()
 Stops all the sound effects in the game More...
 
AudioClip LoadClip (string path, bool add_to_playlist=false)
 Loads an AudioClip from the Resources folder More...
 
void LoadClip (string path, AudioType audio_type, bool add_to_playlist, Action< AudioClip > callback)
 Loads an AudioClip from the specified url path. More...
 
void SaveBGMPreferences ()
 Stores the volume and the mute status of the background music to disk. More...
 
void SaveSFXPreferences ()
 Stores the volume and the mute status of the sound effect to disk. More...
 
void ClearAllPreferences ()
 Removes all key and value pertaining to sound options from disk More...
 
void SaveAllPreferences ()
 Writes all modified sound options or preferences to disk More...
 
void EmptyPlaylist ()
 Clear the list of audio clips More...
 
void AddToPlaylist (AudioClip clip)
 Add a sound clip to list of audio clips More...
 
void RemoveFromPlaylist (AudioClip clip)
 Add a sound clip to asset list pool More...
 
AudioClip GetClipFromPlaylist (string clip_name)
 Gets the AudioClip reference from the name supplied More...
 
void LoadPlaylist (string path, bool overwrite)
 Load all sound clips from the Resources folder path into the asset list pool More...
 

Properties

static AudioManager Instance [get]
 Current and only running instance of the AudioManager More...
 
AudioClip CurrentMusicClip [get]
 Gets the current music clip. More...
 
List< SoundEffectSoundFxPool [get]
 Current list or pool of the sound effects More...
 
List< AudioClip > Playlist [get]
 List of audio clips attached to the AudioManager More...
 
bool IsMusicPlaying [get]
 Is the AudioManager processing any background music More...
 
float MusicVolume [get, set]
 Gets or sets the music volume. More...
 
float SoundVolume [get, set]
 Gets or sets the sound volume. More...
 
bool IsMusicOn [get, set]
 Gets or sets a value indicating whether the music is on. More...
 
bool IsSoundOn [get, set]
 Gets or sets a value indicating whether the sound is on. More...
 
bool IsMasterMute [get, set]
 Gets or sets a value indicating whether this instance is master mute. More...
 

Detailed Description

The manager of all things with regards to sound

Member Function Documentation

◆ AddToPlaylist()

void Papae.UnitySDK.Managers.AudioManager.AddToPlaylist ( AudioClip  clip)

Add a sound clip to list of audio clips

Parameters
clipSound clip data

◆ ClearAllPreferences()

void Papae.UnitySDK.Managers.AudioManager.ClearAllPreferences ( )

Removes all key and value pertaining to sound options from disk

◆ EmptyPlaylist()

void Papae.UnitySDK.Managers.AudioManager.EmptyPlaylist ( )

Clear the list of audio clips

◆ GetClipFromPlaylist()

AudioClip Papae.UnitySDK.Managers.AudioManager.GetClipFromPlaylist ( string  clip_name)

Gets the AudioClip reference from the name supplied

Parameters
clip_nameThe name of the clip in the asset list pool
Returns
The AudioClip from the pool or null if no matching name can be found

◆ IndexOfSoundFxPool()

int Papae.UnitySDK.Managers.AudioManager.IndexOfSoundFxPool ( string  name,
bool  singleton = false 
)

Returns the index of a sound effect in pool if one exists.

Parameters
nameThe name of the sound effect.
singletonIs the sound effect a singleton.
Returns
Index of sound effect or -1 is none exists

◆ LoadClip() [1/2]

AudioClip Papae.UnitySDK.Managers.AudioManager.LoadClip ( string  path,
bool  add_to_playlist = false 
)

Loads an AudioClip from the Resources folder

Parameters
pathPath name of the target clip from the Resources folder
add_to_playlistOption to add loaded clip into the playlist for future reference
Returns
The Audioclip from the resource folder

◆ LoadClip() [2/2]

void Papae.UnitySDK.Managers.AudioManager.LoadClip ( string  path,
AudioType  audio_type,
bool  add_to_playlist,
Action< AudioClip >  callback 
)

Loads an AudioClip from the specified url path.

Parameters
pathThe url path of the audio clip to download. For example: 'http://www.my-server.com/audio.ogg'
audio_typeThe type of audio encoding for the downloaded clip. See AudioType
add_to_playlistOption to add loaded clip into the playlist for future reference
callbackAction callback to be invoked after clip has finished loading

◆ LoadPlaylist()

void Papae.UnitySDK.Managers.AudioManager.LoadPlaylist ( string  path,
bool  overwrite 
)

Load all sound clips from the Resources folder path into the asset list pool

Parameters
pathPathname of the target folder. When using the empty string (i.e, ""), the function will load the entire audio clip content(s) of the resource folder
overwriteOverwrites the current content(s) of the playlist.

◆ PauseAllSFX()

void Papae.UnitySDK.Managers.AudioManager.PauseAllSFX ( )

Pauses all the sound effects in the game

◆ PauseBGM()

void Papae.UnitySDK.Managers.AudioManager.PauseBGM ( )

Pauses the playing background music

◆ PlayBGM() [1/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( AudioClip  clip,
MusicTransition  transition,
float  transition_duration,
float  volume,
float  pitch,
float  playback_position = 0 
)

Plays a background music.

Only one background music can be active at a time.

Parameters
clipThe audio data to play
transitionHow should the music change from the current to the next
transition_durationTime in secs it takes to transition.
volumePlayback volume.
pitchPitch level of the clip.
playback_positionPlay position of the clip.

◆ PlayBGM() [2/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( AudioClip  clip,
MusicTransition  transition,
float  transition_duration,
float  volume 
)

Plays a background music.

Only one background music can be active at a time.

Parameters
clipThe audio data to play
transitionHow should the music change from the current to the next.
transition_durationTime in secs it takes to transition.
volumePlayback volume.

◆ PlayBGM() [3/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( AudioClip  clip,
MusicTransition  transition,
float  transition_duration 
)

Plays a background music.

Only one background music can be active at a time.

Parameters
clipThe audio data to play
transitionHow should the music change from the current to the next.
transition_durationTime in secs it takes to transition.

◆ PlayBGM() [4/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( AudioClip  clip,
MusicTransition  transition 
)

Plays a background music.

Only one background music can be active at a time.

Parameters
clipThe audio data to play
transitionHow should the music change from the current to the next. Use MusicTransition to specify type

◆ PlayBGM() [5/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( AudioClip  clip)

Plays a background music using the swift the transition mode.

Only one background music can be active at a time.

Parameters
clipThe audio data to play

◆ PlayBGM() [6/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( string  clip_path,
MusicTransition  transition,
float  transition_duration,
float  volume,
float  pitch,
float  playback_position = 0 
)

Plays a background music.

Only one background music can be active at a time.

Parameters
clip_pathPath name of the target clip from the Resources folder
transitionHow should the music change from the current to the next.
transition_durationTime in secs it takes to transition.
volumePlayback volume.
pitchPitch level of the clip.
playback_positionPlay position of the clip.

◆ PlayBGM() [7/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( string  clip_path,
MusicTransition  transition,
float  transition_duration,
float  volume 
)

Plays a background music.

Only one background music can be active at a time.

Parameters
clip_pathPath name of the target clip from the Resources folder
transitionHow should the music change from the current to the next.
transition_durationTime in secs it takes to transition.
volumePlayback volume.

◆ PlayBGM() [8/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( string  clip_path,
MusicTransition  transition,
float  transition_duration 
)

Plays a background music.

Only one background music can be active at a time.

Parameters
clip_pathPath name of the target clip from the Resources folder
transitionHow should the music change from the current to the next.
transition_durationTime in secs it takes to transition.

◆ PlayBGM() [9/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( string  clip_path,
MusicTransition  transition 
)

Plays a background music.

Only one background music can be active at a time.

Parameters
clip_pathPath name of the target clip from the Resources folder
transitionHow should the music change from the current to the next. Use MusicTransition to specify type

◆ PlayBGM() [10/10]

void Papae.UnitySDK.Managers.AudioManager.PlayBGM ( string  clip_path)

Plays a background music using the swift the transition mode.

Only one background music can be active at a time.

Parameters
clip_pathPath name of the target clip from the Resources folder

◆ PlayOneShot() [1/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.PlayOneShot ( AudioClip  clip,
Vector2  location,
float  volume,
float  pitch = 1f,
Action  callback = null 
)

Plays a sound effect once at a location in world space and calls the specified callback function after the sound is over

Returns
An AudioSource
Parameters
clipThe audio data to play
locationWorld location of the clip
volumePlayback volume.
pitchPitch level of the clip.
callbackAction callback to be invoked after clip has finished playing

◆ PlayOneShot() [2/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.PlayOneShot ( AudioClip  clip,
Vector2  location,
Action  callback = null 
)

Plays a sound effect once at a location in world space

Returns
An AudioSource
Parameters
clipThe audio data to play
locationWorld location of the clip
callbackAction callback to be invoked after clip has finished playing

◆ PlayOneShot() [3/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.PlayOneShot ( AudioClip  clip,
Action  callback = null 
)

Plays a sound effect once and calls the specified callback function after the sound is over

Returns
An AudioSource
Parameters
clipThe audio data to play
callbackAction callback to be invoked after clip has finished playing

◆ PlaySFX() [1/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.PlaySFX ( AudioClip  clip,
Vector2  location,
float  duration,
float  volume,
bool  singleton = false,
float  pitch = 1f,
Action  callback = null 
)

Plays a sound effect for a duration of time at a given location in world space and calls the specified callback function after the time is over.

Returns
An audiosource
Parameters
clipThe audio data to play
locationWorld location of the clip
durationThe length in time the clip should play
volumePlayback volume.
singletonIs the sound effect a singleton.
pitchPitch level of the clip.
callbackAction callback to be invoked after the sound has finished.

◆ PlaySFX() [2/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.PlaySFX ( AudioClip  clip,
Vector2  location,
float  duration,
bool  singleton = false,
Action  callback = null 
)

Plays a sound effect for a duration of time at a given location in world space and calls the specified callback function after the time is over

Returns
An audiosource
Parameters
clipThe audio data to play
locationWorld location of the clip
durationThe length in time the clip should play
singletonIs the sound effect a singleton.
callbackAction callback to be invoked after the sound has finished.

◆ PlaySFX() [3/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.PlaySFX ( AudioClip  clip,
float  duration,
bool  singleton = false,
Action  callback = null 
)

Plays a sound effect for a duration of time and calls the specified callback function after the time is over

Returns
An audiosource
Parameters
clipThe audio data to play
durationThe length in time the clip should play
singletonIs the sound effect a singleton.
callbackAction callback to be invoked after the sound has finished.

◆ RemoveFromPlaylist()

void Papae.UnitySDK.Managers.AudioManager.RemoveFromPlaylist ( AudioClip  clip)

Add a sound clip to asset list pool

Parameters
clipSound clip data

◆ RepeatSFX() [1/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.RepeatSFX ( AudioClip  clip,
Vector2  location,
int  repeat,
float  volume,
bool  singleton = false,
float  pitch = 1f,
Action  callback = null 
)

Repeats a sound effect for a specified amount of times at a given location in world space and calls the specified callback function after the sound is over.

Returns
An audiosource
Parameters
clipThe audio data to play
locationWorld location of the clip
repeatHow many times in successions you want the clip to play. To loop forever, set as a negative number
volumePlayback volume.
singletonIs the sound effect a singleton.
pitchPitch level of the clip.
callbackAction callback to be invoked after the sound has finished.

◆ RepeatSFX() [2/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.RepeatSFX ( AudioClip  clip,
Vector2  location,
int  repeat,
bool  singleton = false,
Action  callback = null 
)

Repeats a sound effect for a specified amount of times at a given location in world space and calls the specified callback function after the sound is over.

Returns
An audiosource
Parameters
clipThe audio data to play
locationWorld location of the clip
repeatHow many times in successions you want the clip to play. To loop forever, set as a negative number
singletonIs the sound effect a singleton.
callbackAction callback to be invoked after the sound has finished.

◆ RepeatSFX() [3/3]

AudioSource Papae.UnitySDK.Managers.AudioManager.RepeatSFX ( AudioClip  clip,
int  repeat,
bool  singleton = false,
Action  callback = null 
)

Repeats a sound effect for a specified amount of times at a given location in world space and calls the specified callback function after the sound is over.

Returns
An audiosource
Parameters
clipThe audio data to play
repeatHow many times in successions you want the clip to play. To loop forever, set as a negative number
singletonIs the sound effect a singleton.
callbackAction callback to be invoked after the sound has finished.

◆ ResumeAllSFX()

void Papae.UnitySDK.Managers.AudioManager.ResumeAllSFX ( )

Resumes all the sound effect in the game

◆ ResumeBGM()

void Papae.UnitySDK.Managers.AudioManager.ResumeBGM ( )

Resumes the playing background music

◆ SaveAllPreferences()

void Papae.UnitySDK.Managers.AudioManager.SaveAllPreferences ( )

Writes all modified sound options or preferences to disk

◆ SaveBGMPreferences()

void Papae.UnitySDK.Managers.AudioManager.SaveBGMPreferences ( )

Stores the volume and the mute status of the background music to disk.

Note that all preferences would automatically get saved when this script gets destroyed

◆ SaveSFXPreferences()

void Papae.UnitySDK.Managers.AudioManager.SaveSFXPreferences ( )

Stores the volume and the mute status of the sound effect to disk.

Note that all preferences would automatically get saved when this script gets destroyed

◆ StopAllSFX()

void Papae.UnitySDK.Managers.AudioManager.StopAllSFX ( )

Stops all the sound effects in the game

◆ StopBGM()

void Papae.UnitySDK.Managers.AudioManager.StopBGM ( )

Stops the playing background music

Property Documentation

◆ CurrentMusicClip

AudioClip Papae.UnitySDK.Managers.AudioManager.CurrentMusicClip
get

Gets the current music clip.

The current music clip.

◆ Instance

AudioManager Papae.UnitySDK.Managers.AudioManager.Instance
staticget

Current and only running instance of the AudioManager

◆ IsMasterMute

bool Papae.UnitySDK.Managers.AudioManager.IsMasterMute
getset

Gets or sets a value indicating whether this instance is master mute.

true if this instance is master mute; otherwise, false.

◆ IsMusicOn

bool Papae.UnitySDK.Managers.AudioManager.IsMusicOn
getset

Gets or sets a value indicating whether the music is on.

true if this instance is music on; otherwise, false.

◆ IsMusicPlaying

bool Papae.UnitySDK.Managers.AudioManager.IsMusicPlaying
get

Is the AudioManager processing any background music

◆ IsSoundOn

bool Papae.UnitySDK.Managers.AudioManager.IsSoundOn
getset

Gets or sets a value indicating whether the sound is on.

true if this instance is sound on; otherwise, false.

◆ MusicVolume

float Papae.UnitySDK.Managers.AudioManager.MusicVolume
getset

Gets or sets the music volume.

The music volume.

◆ Playlist

List<AudioClip> Papae.UnitySDK.Managers.AudioManager.Playlist
get

List of audio clips attached to the AudioManager

◆ SoundFxPool

List<SoundEffect> Papae.UnitySDK.Managers.AudioManager.SoundFxPool
get

Current list or pool of the sound effects

◆ SoundVolume

float Papae.UnitySDK.Managers.AudioManager.SoundVolume
getset

Gets or sets the sound volume.

The sound volume.


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