class
AudioSource
Represents a source for emitting audio.
Audio can be played spatially (gun shot), or normally (music). Each audio source must have an AudioClip to play-back, and it can also have a position in the case of spatial (3D) audio.
Whether or not an audio source is spatial is controlled by the assigned AudioClip. The volume and the pitch of a spatial audio source is controlled by its position and the AudioListener's position/direction/velocity.
Public
Constructors
AudioSource
Methods
~AudioSource
GetClip
SetVolume
Volume of the audio played from this source, in [0, 1] range.
GetVolume
SetPitch
Determines the pitch of the played audio. 1 is the default.
GetPitch
SetIsLooping
Determines whether the audio clip should loop when it finishes playing.
GetIsLooping
SetPriority
Determines the priority of the audio source.
If more audio sources are playing than supported by the hardware, some might get disabled. By setting a higher priority the audio source is guaranteed to be disabled after sources with lower priority.
GetPriority
SetMinDistance
Minimum distance at which audio attenuation starts.
When the listener is closer to the source than this value, audio is heard at full volume. Once farther away the audio starts attenuating.
GetMinDistance
SetAttenuation
Attenuation that controls how quickly does audio volume drop off as the listener moves further from the source.
GetAttenuation
SetTime
Determines the current time of playback.
If playback hasn't yet started, it specifies the time at which playback will start at. The time is in seconds, in range [0, clipLength].
GetTime
SetPlayOnStart
Sets whether playback should start as soon as the component is enabled.
GetPlayOnStart
Determines should playback start as soon as the component is enabled.
Play
Starts playing the currently assigned audio clip.
Pause
Pauses the audio playback.
Stop
Stops audio playback, rewinding it to the start.
GetState
Returns the current state of the audio playback (playing/paused/stopped).
staticGetRttiStatic
Protected
Constructors
AudioSource
Methods
OnDestroyed
Called once just before the component is destroyed.
Called regardless of the state the component is in.
OnDisabled
Called every time a component is placed into the Stopped state.
This includes component destruction if component wasn't already in Stopped state during destruction. When called during destruction it is called before OnDestroyed.
OnEnabled
Called every time a component leaves the Stopped state, if the component is enabled.
This includes component creation if requirements for leaving the Stopped state are met. When called during creation it is called after OnBeginPlay.
OnTransformChanged
Called when the component's parent scene object has changed.
Not called if the component is in Stopped state. Also only called if necessary notify flags are set via SetNotifyFlagsInternal().
Update
Called once per frame.
Only called if the component is in Running state.
GetListenerResources
Retrieves all the resources that the class depends on.
NotifyResourceChanged
Called when the internal resource the resource handle is pointing to changes.
RestoreInternal
Creates the internal representation of the AudioSource and restores the values saved by the Component.
UpdateTransform
Updates the transform of the internal AudioSource representation from the transform of the component's scene object.