Audio
Inherits from:
Manages and controls all audio-related functionalities within the game engine, including playing music and sounds, and adjusting their properties.
Properties
Indicates whether any audio is currently being played.
Represents the current intensity of the music playing.
Methods
Returns the current music intensity within a specified range.
Parameters
low
number
The lower bound of the intensity range.
high
number
The upper bound of the intensity range.
normalizeVolume
boolean
Whether to normalize the intensity within the specified range.
Returns
number
The current music intensity, possibly normalized.
Temporarily lowers the music volume.
Parameters
duration
number
The duration to lower the music volume.
duckOutDuration
number
Duration for the volume to fade out to the ducked level.
duckInDuration
number
Duration for the volume to return to normal after the specified duration.
Returns
void
Plays music using an AudioShader.
Parameters
shader
AudioShaderThe AudioShader to play.
volume
number
The volume at which to play the music.
Returns
void
Plays music from a specified URL.
Parameters
url
string
The URL of the music to play.
volume
number
The volume at which to play the music.
Returns
void
Stops currently playing music, with an optional fade-out.
Parameters
fadeOut
boolean
Whether to fade out the music instead of stopping abruptly.
Returns
void
Plays an audio effect using an AudioShader.
Parameters
shader
AudioShaderThe AudioShader to use for playing the sound.
Returns
void
Plays a sound effect globally, without spatialization.
Parameters
shader
AudioShaderThe AudioShader to play.
volume
number
The volume at which to play the sound.
pitch
number
The pitch at which to play the sound.
spatialize
boolean
Whether to spatialize the sound. False plays the sound globally.
loop
boolean
Whether the sound should loop.
Returns
The AudioSource instance representing the played sound.
Plays a sound effect attached to a specific game object.
Parameters
shader
AudioShaderThe AudioShader to play.
gameObject
GameObjectThe GameObject to which the sound is attached.
volume
number
The volume at which to play the sound.
pitch
number
The pitch of the sound.
spatialize
boolean
Whether the sound should be spatialized according to the game object's position.
Returns
The AudioSource instance representing the played sound.
Stops a specific audio source.
Parameters
source
AudioSourceThe AudioSource to stop.
Returns
void
Updated 6 months ago