// 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))
object NetworkedAssetLoader
TAG
:
String
[Get] |
Signature
const val TAG: String |
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
assetFetcher:
AssetFetcher |
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
extension:
String
Returns
CompletableFuture
|