AudioSource
Inherits from: Behaviour
AudioSource is a component used to play sounds. You can assign an AudioClip to an AudioSource to control sound playback, adjust volume, change pitch, loop sounds, and manage spatial effects for 3D audio.
Properties
Manages the loudness of the audio playing through the AudioSource. Adjust this property to control volume levels.
Controls the speed of sound playback. Adjusting the pitch changes the sound's speed and pitch.
Sets or returns the current playback position in seconds, allowing for precise control over playback.
Allows setting and retrieving the playback position in PCM samples for precise audio timing.
Holds the AudioClip to be played, allowing for the assignment of sound to the AudioSource.
Indicates if the AudioSource is currently playing sound, useful for checking audio status.
Indicates whether the AudioSource is virtualized, which has minimal resource usage.
When true, the audio clip will play indefinitely in a loop, useful for background music or repeating sounds.
When true, AudioSource ignores global volume controls, playing audio at its own volume level.
Determines if the audio clip will start playing automatically when the script activates.
Allows the AudioSource to keep playing despite a global pause, when set to true.
Controls the left and right stereo pan, aiding in achieving desired sound effects.
Sets the level of 3D audio effect application on the audio playback.
Activates spatializer effect for immersive 3D audio when set to true.
Applies spatial effects to the AudioSource for enhanced audio experience when true.
Controls the mix of spatialized AudioSource into global reverb, enhancing audio depth.
Bypasses applied effects, playing the original sound when true.
Bypasses 3D spatialization effects when true, affecting volume and pitch directly.
Allows bypassing Global Reverb Zones for direct sound play when true.
Sets the amount of Doppler effect, changing sound frequency based on movement.
Controls audio spread across speakers in 3D playback, affecting sound directionality.
Determines the AudioSource's priority among others for managing active AudioSource objects and playback selection based on priority value.
Mutes the AudioSource when true, stopping any sound from being played.
Sets the minimum distance for the AudioSource to start attenuating, controlling volume over distance.
Defines the maximum distance where attenuation stops, setting the farthest point for audio volume reduction.
Methods
Starts playing the assigned audio clip, allowing for sound playback control.
Returns
void
Plays the assigned audio clip after a delay, useful for timed sound effects.
Parameters
delay
number
The delay time in seconds before the audio clip starts playing.
Returns
void
Schedules audio clip playback at a precise time, aiding in synchronized audio events.
Parameters
time
number
The time in seconds when the audio clip will start playing.
Returns
void
Plays an audio clip once on demand, ignoring the AudioSource's regular clip.
Parameters
clip
AudioClipThe audio clip to play once.
Returns
void
Schedules the start time for audio clip playback, organizing audio in precise manner.
Parameters
time
number
The scheduled start time in seconds for the audio clip.
Returns
void
Schedules a stop time for audio clip playback, useful for precise audio event control.
Parameters
time
number
The scheduled end time in seconds for the audio clip.
Returns
void
Stops currently playing audio, useful for immediate sound halt.
Returns
void
Pauses the audio playback, allowing for later resumption from the same point.
Returns
void
Resumes paused audio playback from where it was stopped.
Returns
void
Sets a float parameter for a spatializer effect attached to the AudioSource.
Parameters
index
number
The index of the parameter in the spatializer effect.
value
number
The new value for the specified parameter.
Returns
boolean
Sets a float parameter for an ambisonic decoder plugin attached to the AudioSource.
Parameters
index
number
The index of the parameter in the ambisonic decoder plugin.
value
number
The new value for the specified parameter.
Returns
boolean
Updated 6 months ago