Class AudioClipDownloader
- Namespace
- Bindables
- Assembly
- Bindables.dll
Provides functionality for downloading and caching audio clips from URIs with reference counting.
[InitializeOnLoad]
public static class AudioClipDownloader
- Inheritance
-
AudioClipDownloader
- Inherited Members
Remarks
This class manages audio clip downloads using UnityWebRequest and maintains a cache of downloaded clips. Reference counting ensures that audio clips are only destroyed when no longer in use. In the Unity Editor, all downloads are automatically aborted and released when exiting play mode or edit mode.
Methods
DownloadAsync(string, AudioType)
Downloads an audio clip from the specified URI asynchronously.
public static Task<AudioClip> DownloadAsync(string uri, AudioType type)
Parameters
uristringThe URI of the audio clip to download.
typeAudioTypeThe type of audio file being downloaded (e.g., MP3, WAV, OGG).
Returns
- Task<AudioClip>
A task that represents the asynchronous download operation. The task result contains the downloaded audio clip, or null if the download failed.
Remarks
If the audio clip has already been downloaded and cached, returns the cached clip and increments its reference count. If a download for the same URI is already in progress, waits for that download to complete.
Release(AudioClip)
Releases a reference to the specified audio clip, destroying it if the reference count reaches zero.
public static void Release(AudioClip audioClip)
Parameters
audioClipAudioClipThe audio clip to release.