Audio
The Audio class is responsible for controlling music and sound effects.
Properties
True when music is playing, otherwise false.
An estimation of the perceived loudness of the currently playing audio source.
Length of the music track in seconds.
Time in seconds since the music started.
Current music volume.
Methods
Temporarily lowers the music volume.
Parameters
duration
The duration to lower the music volume.
duckOutDuration
Duration for the volume to fade out to the ducked level.
duckInDuration
Duration for the volume to return to normal after the specified duration.
Returns
Enables radio support in the current room, allowing users to pick a radio station.
Parameters
enabled
currentStation
stationSelected
canModerateRadio
Returns
Returns the current music intensity within a specified range.
Parameters
low
The lower bound of the intensity range.
high
The upper bound of the intensity range.
normalizeVolume
Whether to normalize the intensity within the specified range.
Returns
The current music intensity, possibly normalized.
Plays music using an audio shader. Music played with PlayMusic will be affected by the music volume slider.
Parameters
shader
The audio shader containing the music to play
volume
Volume of the music in the range of 0-1
fadeIn
Whether the music should fade in as it starts playing (Default true)
loop
Whether the music will loop instead of just playing once (Default true)
startTime
Returns
Plays music using a radio station URL. Music played with PlayMusicURL will be affected by the music volume slider.
Parameters
url
The url of the music to play
volume
Volume of the music in the range of 0-1
fadeIn
Whether the music should fade in as it starts playing (Default true)
Returns
Plays an audio effect using an AudioShader.
Parameters
shader
The AudioShader to use for playing the sound.
Returns
Plays a sound effect attached to a specific game object.
Parameters
shader
The AudioShader to play.
gameObject
The GameObject to which the sound is attached.
volume
The volume at which to play the sound.
pitch
The pitch of the sound.
spatialize
Whether the sound should be spatialized according to the game object's position.
loop
Returns
The AudioSource instance representing the played sound.
Plays a sound effect globally, without spatialization.
Parameters
shader
The AudioShader to play.
volume
The volume at which to play the sound.
pitch
The pitch at which to play the sound.
loop
Whether the sound should loop.
Returns
The AudioSource instance representing the played sound.
Set the position and rotation of the audio listener
Parameters
position
rotation
Returns
Stops a specific audio source.
Parameters
source
The AudioSource to stop.
Returns
Stops currently playing music, with an optional fade-out.
Parameters
fadeOut
Whether to fade out the music instead of stopping abruptly.
Returns
Updated 12 days ago