Audio Fade
Updated
Fades a sound in on start and/or out on stop.
- Type
comp-audio-fade- Script class
AudioFadeComponent- Per entity
- One
- Version
- 1.0.0
Read about it in Audio sources: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
duration |
0 ≤ x ≤ 10 |
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
Weather that fades in and outRain and wind ambiences with an Audio Fade each: a Behavior script only enables and disables the two Audio entities, and the fades cross over two seconds.
With your sound on, press Rain: the wind fades out as the rain fades in over two seconds. Press Clear to swap back. The rain is a short loop generated for this example. Drag outside the panel to orbit the camera.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(AudioFadeComponent); if (component) log(component.props);}