API reference
API reference
Select your platform
No SDKs available
No versions available

NetworkedAssetLoader Object

Singleton for downloading and caching remote assets.
Manages the fetching of remote assets and caches them locally to avoid redundant downloads. Must be initialized with NetworkedAssetLoader.init before use.
Example usage:
// Initialize the loader
NetworkedAssetLoader.init(File(applicationContext.getCacheDir().canonicalPath), OkHttpAssetFetcher())
// The ECS will use the networkedAssetLoader to download files that start with "http" and "https"
val modelUrl = Uri.parse("https://example.com/model.glb")
entity.setComponent(Mesh(modelUrl))

Signature

object NetworkedAssetLoader

Properties

TAG : String
[Get]
Signature
const val TAG: String

Functions

destroy ()
Destroys the loader and cleans up any local files.
Lifetime is managed by MeshManager.
Signature
fun destroy()
init ( downloadDirectory , assetFetcher )
Initializes the loader with a download directory and asset fetcher.
Signature
fun init(downloadDirectory: File, assetFetcher: AssetFetcher)
Parameters
downloadDirectory: File
Directory where downloaded assets will be stored
assetFetcher: AssetFetcher
Implementation that handles the actual asset downloading
requestAsset ( url , extension ) : CompletableFuture
Requests an asset from a remote source.
Downloads the asset if not already cached and returns a future with the local file path. The same asset will only be downloaded once, with subsequent requests returning the cached future.
Signature
fun requestAsset(url: Uri, extension: String): CompletableFuture<String>
Parameters
url: Uri
Remote location of the asset
extension: String
File extension to use for the downloaded file
Returns
CompletableFuture
Future that resolves to the local file path when download completes
Did you find this page helpful?
Thumbs up icon
Thumbs down icon