Search documentation

Search documentation pages and sections

Get it

Single Sound

Playback methods for standalone sound effects registered in the Audio Manager.

What is a Single Sound?

A SingleSound is a reference to one audio clip that exists on its own — not inside an AudioCollection. Use it for one-off effects you trigger directly: UI clicks, jumps, item pickups, alerts, and similar isolated sounds.

Each SingleSound controls only its own clip. Calling a method on one reference does not affect other sounds in your scene.

Creating a Single Sound

You need a SingleSound reference before calling any playback method. There are two ways to get one:

Inspector assignment

Declare a field on your script and assign the sound from the Unity Inspector. See Inspector Assignment for the full walkthrough.

C#
public SingleSound singleSound;

Get function

Look up the sound by name at runtime with GetSingleSound. This is useful when the sound name comes from data or the same script handles multiple entities. See Get Functions for details on all lookup methods.

C#
SingleSound jumpSound = AudioSystem.GetSingleSound("PlayerJump");

API Reference

Once you have a reference, use the methods below to control playback.

Play

C#
singleSound.Play()

Starts playback using the default volume and pitch you set for this sound in the Audio Manager window. Restarts from the beginning if the sound is already playing.

Play (volume, pitch)

C#
singleSound.Play(float volume, float pitch)

Starts playback with explicit volume and pitch values. volume is typically between 0f (silent) and 1f (full). pitch uses 1f as the normal playback speed — lower values sound deeper and slower, higher values sound sharper and faster.

Example

C#
singleSound.Play(0.8f, 1.2f);

PlayRandomPitch

C#
singleSound.PlayRandomPitch(float minPitch, float maxPitch)

Plays the sound once with a pitch randomly chosen between minPitch and maxPitch on each call. This adds natural variation so repeated sounds — footsteps, gunfire, UI taps — feel less mechanical without needing separate clips.

Example

C#
singleSound.PlayRandomPitch(0.9f, 1.1f);

Stop

C#
singleSound.Stop()

Stops playback immediately and clears any active fade or pause. For a smooth ending, use FadeOut() instead.

FadeIn

C#
singleSound.FadeIn(float duration, float targetVolume)

Raises volume from the current level to targetVolume over duration seconds.

Example

C#
singleSound.FadeIn(1.5f, 0.8f);

FadeOut

C#
singleSound.FadeOut(float duration)

Lowers volume to silence over duration seconds, then stops playback. Unlike Stop(), the sound winds down instead of cutting off abruptly.

Example

C#
singleSound.FadeOut(0.5f);

Pause

C#
singleSound.Pause()

Holds playback at the current position. The clip stays paused until you call Resume() or Stop().

Resume

C#
singleSound.Resume()

Continues from where Pause() left off. Has no effect if the sound was not paused — use Play() to restart from the beginning.

Common Use Cases

For practical examples — UI feedback, player actions, music fades, and more — see the Common Use Cases page.