Class TextureDownloader
- Namespace
- Bindables
- Assembly
- Bindables.dll
Provides functionality for downloading and caching textures from URIs with reference counting.
[InitializeOnLoad]
public static class TextureDownloader
- Inheritance
-
TextureDownloader
- Inherited Members
Remarks
This class manages texture downloads using UnityWebRequest and maintains a cache of downloaded textures. Reference counting ensures that textures 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, bool)
Downloads a texture from the specified URI asynchronously.
public static Task<Texture2D> DownloadAsync(string uri, bool nonReadable = true)
Parameters
uristringThe URI of the texture to download.
nonReadableboolIf true, the texture's raw data will not be accessible from scripts (uses less memory). Default is true.
Returns
- Task<Texture2D>
A task that represents the asynchronous download operation. The task result contains the downloaded texture, or null if the download failed.
Remarks
If the texture has already been downloaded and cached, returns the cached texture and increments its reference count. If a download for the same URI is already in progress, waits for that download to complete.
Release(Texture2D)
Releases a reference to the specified texture, destroying it if the reference count reaches zero.
public static void Release(Texture2D texture)
Parameters
textureTexture2DThe texture to release.