Audio Manager

Back


Assembly: CarterGames.AudioManager.Runtime

Namespace: CarterGames.Assets.AudioManager


Properties


CanPlayAudio


Property


Returns bool


Toggles whether or not the manager can play audio. This doesn't effect other Audio Manager instances or the other player scripts.


GetNumberOfClips


Property


Returns int


Gets the number of clips currently in this instance of the Audio Manager.


GetRandomSound


Property


Returns AudioClip


Picks a random sound from the current Audio Manager File and returns it.


GetAudioManagerFile


Property


Returns AudioManagerFile


Gets the current Audio Manager File in use.


Methods


HasClip


Method

Declaration

public bool HasClip(string clip);

Returns

bool → Whether or not the clip was found.


Checks to see if a clip exists in the audio manager library.


if (AudioManager.instance.HasClip("MyClip"))
{
		// Do some stuff...
}

IsClipPlaying


Method

Declaration

public bool IsClipPlaying(string clip);

Returns

bool → Whether or not the clip is currently playing.


Checks to see if the clip in question is playing.


if (AudioManager.instance.IsClipPlaying("MyClip"))
{
		// Do some stuff...
}

Play


Method

Declarations

public void Play(string clip, float volume = 1f, float pitch = 1f);
public void Play(string clip, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void Play(string clip, int mixerId, float volume = 1f, float pitch = 1f);
public void Play(string clip, AudioArgs args);

Parameters

string → The name of the clip to play.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Plays the requested clip with optional values for volume and pitch. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


AudioManager.instance.Play("MyClip");
AudioManager.instance.Play("MyClip", mixer);
AudioManager.instance.Play("MyClip", mixerID);
AudioManager.instance.Play("MyClip", args);

PlayAndGetSource


Method

Declarations

public AudioSource PlayAndGetSource(string clip, float volume = 1f, float pitch = 1f);
public AudioSource PlayAndGetSource(string clip, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayAndGetSource(string clip, int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayAndGetSource(string clip, AudioArgs args);

Parameters

string → The name of the clip to play.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Returns

AudioSource → The source the clip is now playing on.


Play a sound that is scanned into the audio manager and return the audio source the clip is on for you to check / use as needed. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


var source = AudioManager.instance.PlayAndGetSource("MyClip");
var source = AudioManager.instance.PlayAndGetSource("MyClip", mixer);
var source = AudioManager.instance.PlayAndGetSource("MyClip", mixerID);
var source = AudioManager.instance.PlayAndGetSource("MyClip", args);

PlayFromTime


Method

Declarations

public void PlayFromTime(string clip, float time, float volume = 1f, float pitch = 1f);
public void PlayFromTime(string clip, float time, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void PlayFromTime(string clip, float time, int mixerId, float volume = 1f, float pitch = 1f);
public void PlayFromTime(string clip, float time, AudioArgs args);

Parameters

string → The name of the clip to play.

float → The time to play the clip from.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Plays the requested clip with optional values for volume and pitch from the set time, handy if the clip doesn’t start right away. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


AudioManager.instance.PlayFromTime("MyClip", 0.1f);
AudioManager.instance.PlayFromTime("MyClip", 0.1f, mixer);
AudioManager.instance.PlayFromTime("MyClip", 0.1f, mixerID);
AudioManager.instance.PlayFromTime("MyClip", 0.1f, args);

PlayFromTimeAndGetSource


Method

Declarations

public AudioSource PlayFromTimeAndGetSource(string clip, float time, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromTimeAndGetSource(string clip, float time, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromTimeAndGetSource(string clip, float time, int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromTimeAndGetSource(string clip, float time, AudioArgs args);

Parameters

string → The name of the clip to play.

float → The time to play the clip from.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Returns

AudioSource → The source the clip is now playing on.


Plays the requested clip with optional values for volume and pitch from the set time, handy if the clip doesn’t start right away. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


var source = AudioManager.instance.PlayFromTimeAndGetSource("MyClip", 0.1f);
var source = AudioManager.instance.PlayFromTimeAndGetSource("MyClip", 0.1f, mixer);
var source = AudioManager.instance.PlayFromTimeAndGetSource("MyClip", 0.1f, mixerID);
var source = AudioManager.instance.PlayFromTimeAndGetSource("MyClip", 0.1f, args);

PlayWithDelay


Method

Declarations

public void PlayWithDelay(string clip, float delay, float volume = 1f, float pitch = 1f);
public void PlayWithDelay(string clip, float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void PlayWithDelay(string clip, float delay, int mixerId, float volume = 1f, float pitch = 1f);
public void PlayWithDelay(string clip, float delay, AudioArgs args);

Parameters

string → The name of the clip to play.

float → The delay before playing the clip.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Plays the requested clip with optional values for volume and pitch after the entered delay. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


AudioManager.instance.PlayWithDelay("MyClip", 0.1f);
AudioManager.instance.PlayWithDelay("MyClip", 0.1f, mixer);
AudioManager.instance.PlayWithDelay("MyClip", 0.1f, mixerID);
AudioManager.instance.PlayWithDelay("MyClip", 0.1f, args);

PlayWithDelayAndGetSource


Method

Declarations

public AudioSource PlayWithDelayAndGetSource(string clip, float delay, float volume = 1f, float pitch = 1f);
public AudioSource PlayWithDelayAndGetSource(string clip, float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayWithDelayAndGetSource(string clip, float delay, int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayWithDelayAndGetSource(string clip, float delay, AudioArgs args);

Parameters

string → The name of the clip to play.

float → The delay before playing the clip.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Returns

AudioSource → The source the clip is now playing on.


Plays the requested clip with optional values for volume and pitch after the entered delay. Also returns the audio source the clip is on for you to check / use as needed. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


var source = AudioManager.instance.PlayWithDelayAndGetSource("MyClip", 0.1f);
var source = AudioManager.instance.PlayWithDelayAndGetSource("MyClip", 0.1f, mixer);
var source = AudioManager.instance.PlayWithDelayAndGetSource("MyClip", 0.1f, mixerID);
var source = AudioManager.instance.PlayWithDelayAndGetSource("MyClip", 0.1f, args);

PlayAtLocation


Method

Declarations

public void PlayAtLocation(string clip, Vector3 position, float volume = 1f, float pitch = 1f);
public void PlayAtLocation(string clip, Vector3 position, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void PlayAtLocation(string clip, Vector3 position, int mixerId, float volume = 1f, float pitch = 1f);
public void PlayAtLocation(string clip, Vector3 position, AudioArgs args);

Parameters

string → The name of the clip to play.

Vector3 → The position to play the clip at.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Plays the requested clip at the position entered with optional values for volume and pitch after the entered delay. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


Vector3 pos = transform.position;

AudioManager.instance.PlayAtLocation("MyClip", pos);
AudioManager.instance.PlayAtLocation("MyClip", pos, mixer);
AudioManager.instance.PlayAtLocation("MyClip", pos, mixerID);
AudioManager.instance.PlayAtLocation("MyClip", pos, args);

PlayAtLocationAndGetSource


Method

Declarations

public AudioSource PlayAtLocationAndGetSource(string clip, Vector3 position, float volume = 1f, float pitch = 1f);
public AudioSource PlayAtLocationAndGetSource(string clip, Vector3 position, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayAtLocationAndGetSource(string clip, Vector3 position, int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayAtLocationAndGetSource(string clip, Vector3 position, AudioArgs args);

Parameters

string → The name of the clip to play.

Vector3 → The position to play the clip at.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Returns

AudioSource → The source the clip is now playing on.


Plays the requested clip at the position entered with optional values for volume and pitch after the entered delay. Also returns the audio source the clip is on for you to check / use as needed. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


Vector3 pos = transform.position;

var source = AudioManager.instance.PlayAtLocationAndGetSource("MyClip", pos);
var source = AudioManager.instance.PlayAtLocationAndGetSource("MyClip", pos, mixer);
var source = AudioManager.instance.PlayAtLocationAndGetSource("MyClip", pos, mixerID);
var source = AudioManager.instance.PlayAtLocationAndGetSource("MyClip", pos, args);

PlayFromRange


Method

Declarations

public void PlayFromRange(List<string> clips, float delay, float volume = 1f, float pitch = 1f);
public void PlayFromRange(List<string> clips, float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void PlayFromRange(List<string> clips, float delay, int mixerId, float volume = 1f, float pitch = 1f);
public void PlayFromRange(List<string> clips, float delay, AudioArgs args);
public void PlayFromRange(string[] clips, float delay, float volume = 1f, float pitch = 1f);
public void PlayFromRange(string[] clips, float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void PlayFromRange(string[] clips, float delay, int mixerId, float volume = 1f, float pitch = 1f);
public void PlayFromRange(string[] clips, float delay, AudioArgs args);

Parameters

List<string> string[] → The names of the clips to play.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Plays a random clip from the entered strings with optional values for volume and pitch. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


AudioManager.instance.PlayFromRange(new string[] { "MyClip", "MyOtherClip" });

PlayFromRangeAndGetSource


Method

Declarations

public AudioSource PlayFromRangeAndGetSource(List<string> clips, float delay, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromRangeAndGetSource(List<string> clips, float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromRangeAndGetSource(List<string> clips, float delay, int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromRangeAndGetSource(List<string> clips, float delay, AudioArgs args);
public AudioSource PlayFromRangeAndGetSource(string[] clips, float delay, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromRangeAndGetSource(string[] clips, float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromRangeAndGetSource(string[] clips, float delay, int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayFromRangeAndGetSource(string[] clips, float delay, AudioArgs args);

Parameters

List<string> string[] → The names of the clips to play.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Returns

AudioSource → The source the clip is now playing on.


Plays a random clip from the entered strings and return the audio source the clip is on for you to check / use as needed. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


var source = AudioManager.instance.PlayFromRangeAndGetSource(new string[] { "MyClip", "MyOtherClip" });

PlayRandom


Method

Declarations

public void PlayRandom(float volume = 1f, float pitch = 1f);
public void PlayRandom(AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void PlayRandom(int mixerId, float volume = 1f, float pitch = 1f);
public void PlayRandom(AudioArgs args);

Parameters

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Plays a random clip from the audio manager library with optional values for volume and pitch. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


AudioManager.instance.PlayRandom(float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandom(AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandom(int mixerId, float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandom(AudioArgs args);

PlayRandomAndGetSource


Method

Declarations

public AudioSource PlayRandomAndGetSource(float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomAndGetSource(AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomAndGetSource(int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomAndGetSource(AudioArgs args);

Parameters

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Returns

AudioSource → The source the clip is now playing on.


Plays a random clip from the audio manager library with optional values for volume and pitch. Also returns the audio source the clip is on for you to check / use as needed. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


var source = AudioManager.instance.PlayRandomAndGetSource(float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomAndGetSource(AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomAndGetSource(int mixerId, float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomAndGetSource(AudioArgs args);

PlayRandomFromTime


Method

Declarations

public void PlayRandomFromTime(float time, float volume = 1f, float pitch = 1f);
public void PlayRandomFromTime(float time, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void PlayRandomFromTime(float time, int mixerId, float volume = 1f, float pitch = 1f);
public void PlayRandomFromTime(float time, AudioArgs args);

Parameters

float → The time to play the clip from.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Plays a random clip from the audio manager library with optional values for volume and pitch from the set time. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


AudioManager.instance.PlayRandomFromTime(float time, float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandomFromTime(float time, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandomFromTime(float time, int mixerId, float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandomFromTime(float time, AudioArgs args);

PlayRandomFromTimeAndGetSource


Method

Declarations

public AudioSource PlayRandomAndGetSource(float time, float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomAndGetSource(float time, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomAndGetSource(float time, int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomAndGetSource(float time, AudioArgs args);

Parameters

float → The time to play the clip from.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Returns

AudioSource → The source the clip is now playing on.


Plays a random clip from the audio manager library with optional values for volume and pitch from the set time. Also returns the audio source the clip is on for you to check / use as needed. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


var source = AudioManager.instance.PlayRandomFromTimeAndGetSource(float time, float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomFromTimeAndGetSource(float time, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomFromTimeAndGetSource(float time, int mixerId, float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomFromTimeAndGetSource(float time, AudioArgs args);

PlayRandomWithDelay


Method

Declarations

public void PlayRandomWithDelay(float delay, float volume = 1f, float pitch = 1f);
public void PlayRandomWithDelay(float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public void PlayRandomWithDelay(float delay, int mixerId, float volume = 1f, float pitch = 1f);
public void PlayRandomWithDelay(float delay, AudioArgs args);

Parameters

float → The delay before playing the clip.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Plays a random clip from the audio manager library with optional values for volume and pitch after the entered delay. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


AudioManager.instance.PlayRandomWithDelay(float delay, float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandomWithDelay(float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandomWithDelay(float delay, int mixerId, float volume = 1f, float pitch = 1f);
AudioManager.instance.PlayRandomWithDelay(float delay, AudioArgs args);

PlayRandomWithDelayAndGetSource


Method

Declarations

public AudioSource PlayRandomWithDelayAndGetSource(float delay, float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomWithDelayAndGetSource(float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomWithDelayAndGetSource(float delay, int mixerId, float volume = 1f, float pitch = 1f);
public AudioSource PlayRandomWithDelayAndGetSource(float delay, AudioArgs args);

Parameters

float → The delay before playing the clip.

AudioMixerGroup → The mixer group to play in.

int → The id of the mixer to play in from the Audio Manager inspector.

AudioArgs/Hashtable → The audio args or hash-table to setup the player.

float optional → The volume for the clip (between 0, 1).

float optional → The pitch for the clip (between -3, 3).


Returns

AudioSource → The source the clip is now playing on.


Plays a random clip from the audio manager library with optional values for volume and pitch after the entered delay. Also returns the audio source the clip is on for you to check / use as needed. There are several overload methods are also available for audio mixers, either by manual assignment or via the audio manager mixer ID number.


var source = AudioManager.instance.PlayRandomWithDelayAndGetSource(float delay, float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomWithDelayAndGetSource(float delay, AudioMixerGroup mixerGroup, float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomWithDelayAndGetSource(float delay, int mixerId, float volume = 1f, float pitch = 1f);
var source = AudioManager.instance.PlayRandomWithDelayAndGetSource(float delay, AudioArgs args);