Playing Sound

Since a sound source just extends the functionality of an audio source, working with audio clips is essentially the same.

Getting An Audio Clip

If you've set up the USound Setup component correctly, and placed all of your audio clips in the right folders, you will be able to play audio clips by their short paths.

var clip = USoundManager.GetAudioClip("Example Folder/Clip Name");

Playing/Stopping An Audio Clip

To play an audio clip, you would have to set it first.

soundSource.SetClip(clip);
soundSource.Play();

Alternatively, you can find, set, and play an audio clip with the code below.

soundSource.Play("Example Folder/Clip Name");

Stopping isn't any different from an audio source.

soundSource.Stop();

Adjusting Volume

It's recommended to use SoundSource.SetVolume or SoundSource.SetVolumeScale as the only ways to change the volume.

// Set volume (0 - 1)
soundSource.SetVolume(0.5f);

// Set volume scale (0 - 1)
soundSource.SetVolumeScale(0.5f);

Other Properties

If you're wondering how to set other properties that you would find in an audio source, it's safe to use the audio source itself with SoundSource.audioSource.

// Setting the spatial blend to 3D with the audio source
soundSource.audioSource.spatialBlend = 1f;

// Alternative method
soundSource.Set3D();

Last updated