AudioService
Manages and controls all aspects of audio playback, including music, sound effects, and voice within the game environment. Offers functionalities like playing, stopping, and adjusting audio properties.
Methods
Checks if any audio is currently playing.
Returns
Returns true if audio is playing; otherwise, false.
Retrieves the current music intensity level.
Returns
Current intensity of the playing music.
Gets the volume level music is ducked to during audio ducking.
Returns
The volume level music is ducked to.
Temporarily lowers the music volume for a specified duration.
Parameters
duration
How long the music volume is lowered.
duckOutDuration
Time to transition music volume to the ducked level.
duckInDuration
Time to restore music volume back to normal after ducking.
Returns
Plays music using an AudioShader.
Parameters
shader
AudioShaderThe AudioShader used to play music.
volume
The volume at which the music should be played.
Returns
Plays music from a specified URL.
Parameters
url
The URL of the music to be played.
volume
The volume at which the music should be played.
Returns
Stops currently playing music, with an option to fade out.
Parameters
fadeOut
Whether the music should fade out instead of stopping abruptly.
Returns
Plays an audio effect using an AudioShader.
Parameters
shader
AudioShaderThe AudioShader used to play the audio effect.
Returns
Plays a sound effect globally, without spatialization.
Parameters
shader
AudioShaderThe AudioShader representing the sound to be played.
volume
Volume of the sound.
pitch
Pitch adjustment of the sound.
spatialize
Whether the sound should be spatialized.
loop
Whether the sound should loop.
Returns
The AudioSource through which the sound is played.
Plays a sound effect attached to a specific GameObject, allowing for spatial audio effects.
Parameters
shader
AudioShaderThe AudioShader used to play the sound.
gameObject
GameObjectThe GameObject to which the sound is attached, allowing it to emit sound from its location in the game world.
volume
Volume at which the sound should be played.
pitch
Pitch adjustment for the sound, allowing for higher or lower playback tones.
spatialize
Whether the sound should be spatialized, giving it a position in the 3D space of the game.
Returns
The AudioSource instance through which the sound is played, allowing for further manipulation.
Stops playback of an audio source.
Parameters
source
AudioSourceThe AudioSource instance that should be stopped.