Prefixes

The Sounds Good API follows a clear semantic convention so you can read the code almost like a sentence:

Prefix
Meaning
Returns
Chainable

Set

Configures or assigns a value before / during playback.

The same instance (this).

✔️

On

Declares a callback that fires on a lifecycle event.

The same instance (this).

✔️

Methods without prefix (Play, Pause, Stop, Resume)

Immediate action on the audio.

void


🛠️ Set prefix

Every function that starts with Set stores parameters on the object and returns it so you can keep chaining:

new Sound(SFX.Explosion)
    .SetVolume(0.55f)
    .SetRandomPitch()           // variation to avoid repetition
    .SetSpatialSound(true)      // 3D
    .SetFadeOut(0.8f)           // fade when it ends
    .Play();

💡 Create first, set afterwards, finish with play.


🔔 On prefix

On… methods let you subscribe to events without coroutines or repetitive Invokes:

var loopingMusic = new Music(Track.ForestAmbience)
    .SetLoop(true)
    .OnPlay(()      => Debug.Log("Ambient started"))
    .OnPause(()     => Debug.Log("Ambient paused"))
    .OnResume(()    => Debug.Log("Ambient resumed"))
    .OnComplete(()  => Debug.Log("Ambient stopped"));

loopingMusic.Play();    // fires OnPlay

// Later…
loopingMusic.Pause();   // fires OnPause
loopingMusic.Resume();  // fires OnResume
loopingMusic.Stop();    // fires OnComplete

Last updated