Audio Zone 2D
While the listener is inside Area, Bus is turned to Gain.
component audio.AudioZone2D
On this page
Try it
Change a zone's bus gain
The listener is inside the purple zone, which selects a world-layer target of 0.25 for the music bus. The marker reads that target from the audio service. No sound is played.
Set Gain to 0.75. After the scene restarts, the real zone changes the world's music-bus target and the marker turns green. Fade is zero; Reset returns the target to 0.25.
Starts the scene; open the example parameters to experiment.
Scene3 nodes
Scriptmain.aes
package demo
import "aego/audio"
// The marker reads the target selected by the audio service, not Zone.Gain.
// There is no audio source: observing the mixer does not play a sound.
script GainIndicator {
func Update(dt float) {
if audio.WorldBusGain(audio.Bus.Music) > 0.5 {
node.Get<SpriteRenderer>().Tint = Color{0.05, 0.8, 0.25, 1}
} else {
node.Get<SpriteRenderer>().Tint = Color{1, 0.5, 0.05, 1}
}
}
}
Fields
| Name | Type | Default | Description |
|---|---|---|---|
| Area | Rect | (-4, -3, 8, 6) | Rectangle in this node's space. |
| Bus | enum | music | Bus the zone turns down or up. one of: master, music, sfx, ui, ambience, voice |
| Gain | float | 0.5 | Volume of the bus inside the zone, 0 to 1. 0 – 1 |
| Priority | int | 0 | Among overlapping zones on one bus the highest priority wins, then the one entered later. |
| Fade Time | float | 0.5 | Seconds to fade in and out of the zone. ≥ 0 |