Audio objects

Audio objects are instances you create from code to play the sounds or music you previously registered in Audio Creator. Each class encapsulates specific rules and behaviours and offers a fluent, method-chaining API.

Object
What it represents
Typical use

Sound

A single SFX (footstep, shot, UI click…) that might play many times.

Any kind of sound effect.

Music

One music track (ambient, boss theme…) that can loop.

Constant background music.

Playlist

A sequential queue of tracks; plays in order, supports shuffle, fade-in/out and per-track callbacks.

Background music made of several tracks in succession.

DynamicMusic

Several tracks playing in parallel, letting you add/remove layers (drums, strings, SFX) according to gameplay.

Reactive dynamic music.

đź§° Key concepts

  • Fluent API – Every setter returns the same instance, so you can chain configuration and the final Play() in one sentence.

  • Automatic Object Pooling – Internally, each object requests a SoundsGoodAudioSource from the pool, avoiding runtime instantiation.

  • Callbacks (OnPlay, OnComplete, etc.) – Hook gameplay logic (screen shake, particles, achievements) without coroutines or Invoke.

  • Volume persistence – If you assign an Output, its level is saved to PlayerPrefs; Output Manager restores it on start-up.

  1. Create

    var coinSound = new Sound(SFX.Coin).SetVolume(0.7f);
  2. Play / control

    coinSound.Play();
    coinSound.Pause();
    coinSound.Resume(0.5f); // 0.5-second fade-in
    coinSound.Stop(0.2f);   // 0.2-second fade-out
  3. Finish

    • When it ends (OnComplete), the object returns its AudioSource to the pool.

    • The class instance stays alive; you can reconfigure it and call Play() again.

📝 Tip: Don’t instantiate an audio object every frame; keep references if you’ll reuse the same SFX (footsteps, rapid fire, etc.).

🚀 Next step

Dive into each audio object to master every feature:

Last updated