Skip to Content
Version 1Sounds

Sound and Audio

LUI can play UI interaction sounds with no per-element wiring. The theme supplies one clip per interaction type, and you opt an element in with a sound-* utility class (pointer driven) or play a sound imperatively from code.

Theme Clips

LuiTheme exposes one clip per interaction, a master volume, and a global mute:

Theme fieldUsed for
soundHoverPointer enters a sound-hover / sound-button element
soundClickA sound-click / sound-button element is clicked
soundOpenOpen interaction, usually played via Lui.PlaySound(LuiSound.Open)
soundCloseClose interaction, including modal X and sound-close
soundConfirmConfirm interaction, including Confirm dialog accept and sound-confirm
soundCancelCancel interaction, including Confirm dialog cancel and sound-cancel
soundVolumeMaster volume from 0 to 1 for all interaction sounds
muteSoundsSuppresses every interaction sound when enabled

All clips play through a single shared, persistent AudioSource created on first use, so there is no setup in the scene.

Utility Classes

Add a sound-* class to map an element’s pointer interactions to a theme clip:

UtilityBehavior
sound-buttonPlays hover on pointer enter and click on click; the common path for buttons
sound-clickPlays click on click
sound-hoverPlays hover on pointer enter
sound-confirmPlays confirm on click
sound-cancelPlays cancel on click
sound-openPlays open on click
sound-closePlays close on click
sound-noneSuppresses sounds on this element
Lui.Button("Play", "px-4 py-2 rounded-lg bg-primary sound-button", OnPlay) Lui.Div("p-4 sound-hover").OnClick(Select)

Sounds are suppressed automatically on disabled and loading elements, matching their other interactions.

Fluent Equivalent

.Sound(click, hover) sets the same thing without class tokens:

Lui.Button("Confirm", classes, OnConfirm).Sound(LuiSound.Confirm) Lui.Button("Play", classes, OnPlay).Sound(LuiSound.Click, LuiSound.Hover) // == sound-button

Imperative Playback

For sounds that aren’t pointer driven - most commonly playing Open when an overlay is toggled open from code - call Lui.PlaySound:

void OpenMenu() { _menuOpen.Value = true; Lui.PlaySound(LuiSound.Open); }

Built-in Overlay Sounds

The built-in overlays are pre-wired so they sound automatically once the matching theme clips are assigned:

Overlay surfaceSound behavior
Modal X close buttonPlays Close
LuiOverlay.ConfirmPlays Confirm on accept and Cancel on the cancel button
Custom LuiModalActionsAccept a sound: argument, such as LuiModalAction.Primary(label, onClick, sound: LuiSound.Confirm)

Sound Values

ValueMeaning
NoneNo sound
HoverTheme hover clip
ClickTheme click clip
OpenTheme open clip
CloseTheme close clip
ConfirmTheme confirm clip
CancelTheme cancel clip

Demo

See ReadySoundComponent (the Sound tab in the components showcase) for the sound-* classes, the imperative Lui.PlaySound(LuiSound.Open) button, a disabled-silences toggle, and a Confirm dialog wired for Confirm/Cancel sounds. Assign clips to the active theme to hear them.

Last updated on