Sound - rmfandyplayz/UnityUIAnimationTools GitHub Wiki

A Play Sound step plays a clip at its moment in the animation. Put one first in a Press animation and you have a button click. Put one at a 0.15 second delay in a Show and it lands with the pop.

▼ AFTER  ui_click (Play Sound)
    Start              [AFTER PREVIOUS]
    Type               Play Sound
    Audio Source       None            ← usually leave empty
    Clip               ui_click
    Volume             1
    Pitch              1
    Pitch Variation    0.08
    Delay              0

Where the sound plays from

In order:

  1. The step's Audio Source, if you set one.
  2. An Audio Source on the player's own object, if it has one.
  3. Otherwise, a shared 2D Audio Source the tool makes for you.

The third one is the point: you can add a click to forty buttons without adding forty Audio Sources. It shows up in the Hierarchy as UI Animation Audio under DontDestroyOnLoad while the game runs. It's 2D, so it sounds the same wherever the camera is, and it keeps playing while the game is paused.

Pitch Variation

A random amount added to or taken from Pitch each time the sound plays. 0.08 is enough to stop a repeated click sounding robotic.

Volume sliders and mixers

To route UI sounds through an Audio Mixer (for a "UI volume" slider), either:

  • set a mixer-connected Audio Source on the step, or
  • replace the shared source once when the game starts:
UIAnimationAudio.SetShared(myUISfxSource);

Good to know

  • Sounds overlap rather than cutting each other off.
  • Stopping an animation doesn't stop a sound it already started. A sound that was still waiting for its moment simply never plays.
  • Sounds don't play in the edit-mode preview. Check them in play mode.
  • Jumping an animation to its end skips its sounds, rather than firing every skipped sound at once. See Interrupting and Chaining.
  • A Play Sound step with no Clip shows a ⚠ and is skipped.
Under the hood
  • Clips play with PlayOneShot, which is why they overlap.
  • Pitch belongs to the Audio Source, not to one sound. Setting it also shifts any sound still playing on that same source. You won't hear it on clicks; if it matters, give that step its own Audio Source.
  • Audio ignores Time.timeScale, and the shared source has ignoreListenerPause on, so pause-menu sounds work with no setup.
  • The shared source only exists in play mode. Outside it, UIAnimationAudio.Shared is null, because DontDestroyOnLoad throws there after the object has already been created, which would leave a stray object in your scene each time.
  • Sound steps fire at their exact time, not snapped to a custom FPS grid.
⚠️ **GitHub.com Fallback** ⚠️