AudioClipExt.PlayAsync Method
Asynchronous and ubiquitously plays the AudioClip.
Namespace: UltimateXR.Extensions.Unity.Audio
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0
Syntax
C#
public static Task PlayAsync(
this AudioClip self,
float volume = 1f,
float delay = 0f,
float pitch = 1f,
CancellationToken ct = default
)
Parameters
- self
- Type: AudioClip
Reference to the sound clip file that will be played. - 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. - 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.PlayClipAsync(AudioClip, Single, Single, Single, CancellationToken)