Search documentation

Search documentation pages and sections

Get it

Inspector Assignment

Expose Unity Audio Manager sounds in the Unity Inspector and assign them visually — the same way you would with public floats, GameObjects, and other serialized fields.

Overview

The Unity Audio Manager lets you reference sounds directly from your scripts and surface those references in the Unity Inspector. Instead of looking up sounds by name at runtime, you can wire them up in the editor and select them from a dropdown.

Inspector assignment is ideal for sounds you know ahead of time — player movement effects, UI feedback, background music, and anything else that does not need to change dynamically. If you prefer to resolve sounds in code, see the Get Functions guide.

How It Works

Declare a field using one of the Audio Manager sound types — AudioCollection, SingleSound, or SoundFromGroup — and mark it as serializable with [SerializeField] or by making it public.

Once exposed, the field appears in the Inspector when your script is attached to a GameObject. Unity presents a dropdown populated with the sounds you have defined in the Audio Manager, so you can pick the right one without writing any lookup code.

Using SerializeField

Use [SerializeField] when you want a field to appear in the Inspector while keeping it private in your script. This is the recommended approach for encapsulation.

C#
[SerializeField] private AudioCollection musicCollection;  // Visible in Inspector
[SerializeField] private SingleSound jumpSound;           // Visible in Inspector
[SerializeField] private SoundFromGroup footsteps;        // Visible in Inspector

Using Public Fields

Public fields are serialized by default in Unity, so they appear in the Inspector automatically. This is a straightforward option when you do not need to restrict access to the field.

C#
public AudioCollection musicCollection;
public SingleSound jumpSound;
public SoundFromGroup footsteps;

Renaming Sounds

Inspector assignments are tied to the sound name registered in the Audio Manager. If you rename a sound in the Audio System window, any scripts that reference it through the Inspector will lose that connection.

After renaming a sound, revisit the affected components and reassign the field in the Inspector. Runtime lookups by name have the same constraint — see Get Functions for details on referencing sounds in code.

Tip: settle on final sound names early in development, or plan to reassign Inspector fields whenever you rename sounds in the Audio Manager.

Sound Types

If you are unsure what AudioCollection, SingleSound, or SoundFromGroup are, see the Sound Types page for a full breakdown of each type.