Managing Sound Sources

Remember to use the Esper.USound namespace when scripting.

A Sound Source is just an extension of an Audio Source. You can access the audio source by simply using SoundSource.audioSource.

Creating a Sound Source

Creating a sound source can be done in a single line. Here we create a sound source with the name FX.

SoundSource fxSource = USoundManager.CreateNewCustom("FX");

Remember, sound source names need to be unique (except for copies). We can create a copy of FX as so:

SoundSource fxCopy = fxSource.CreateCopy("FX Copy");

Getting a Sound Source

Defaults

You can access the default one-shot and background music sound sources by their cached variables.

SoundSource oneShotSource = USoundManager.defaultOneShotSource;
SoundSource bgmSource = USoundManager.defaultBGMSource;

Custom

You can find a custom sound source with it's unique name.

SoundSource soundSource = USoundManager.FindCustom("Unique Name");

Copy

A copy of a sound source is saved in the sound source that was copied. Copies are for very niche purposes and there is no 'good' way of getting one.

// Getting a copy by name (returns the first one with the provided name)
SoundSource copy = mainSoundSource.GetCopy("Copy Name");
// Getting a copy by index
SoundSource copy = mainSoundSource.GetCopy(0);

It's recommended that a copy is cached when created if you need to edit it's values for whatever reason.

SoundSource copy = mainSoundSource.CreateCopy("Copy Name");

The name of a copy does not need to be unique.

Deleting a Sound Source

Default sound sources cannot be deleted. A main sound source can be deleted like this:

USoundManager.DeleteCustom("Name");

A copy must be deleted from the main sound source that was copied.

// Deleting by name
mainSoundSource.DeleteCopy("Copy Name");

// Deleting by index
mainSoundSource.DeleteCopy(0);

Last updated