AudioClipExt.PlayAtPointAsync Method
Asynchronously plays the AudioClip at a given position in world space.
Namespace: UltimateXR.Extensions.Unity.Audio
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0
Syntax
C#
public static Task PlayAtPointAsync(
this AudioClip self,
Vector3 point,
float volume = 1f,
float delay = 0f,
float pitch = 1f,
float spatialBlend = 0.9f,
CancellationToken ct = default
)
Parameters
- self
- Type: AudioClip
Reference to the sound clip file that will be played. - point
- Type: Vector3
Position in world space from which sound originates. - volume (Optional)
- Type: System.Single
How loud the sound is at a distance of one world unit (one meter) [0.0, 1.0]. - delay (Optional)
- Type: System.Single
Delay time specified in seconds. - pitch (Optional)
- Type: System.Single
Amount of change in pitch due to slowdown/speed up of the Audio Clip. Value 1 is normal playback speed. - spatialBlend (Optional)
- Type: System.Single
Sets how much the 3D engine has an effect on the audio source [0.0, 1.0]. - ct (Optional)
- Type: System.Threading.CancellationToken
CancellationToken to stop playing.
Return Value
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type AudioClip. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
This function creates an AudioSource but automatically disposes of it once the clip has finished playing.
See Also
Reference
AudioClipExt Class
UltimateXR.Extensions.Unity.Audio Namespace
AudioSourceExt.PlayClipAtPointAsync(AudioClip, Vector3, Single, Single, Single, Single, CancellationToken)