load

inline suspend fun <T> load(path: String, parameters: AssetLoaderParameters<T>? = null): T

Schedules loading of an asset of T type located at path. Suspends the coroutine until an asset is loaded and returns a fully loaded instance of T.

path must be compatible with the fileResolver. Loading parameters are optional and can be used to configure the loaded asset.

Might throw the following exceptions:

If the asset was already loaded, added or scheduled for loading, this method will not fail or throw an exception (unless the original loading fails). Instead, the coroutine will be suspended until the original loading is finished and then return the same result.

Note that to unload an asset, unload method should be called the same amount of times as load. Asset dependencies should not be unloaded directly; instead, unload the asset that required them and caused them to load in the first place.

If the parameters define a AssetLoaderParameters.loadedCallback, it will be invoked on the main rendering thread after the asset is loaded successfully with this AssetStorage wrapped as an AssetManager with AssetManagerWrapper. Note that the wrapper supports a limited number of methods. It is encouraged not to rely on AssetLoaderParameters.LoadedCallback and use coroutines instead. Exceptions thrown by callbacks will not be propagated, and will be logged with logger instead.


suspend fun <T> load(identifier: Identifier<T>, parameters: AssetLoaderParameters<T>? = null): T

Schedules loading of an asset with path and type specified by identifier. Suspends the coroutine until an asset is loaded and returns a fully loaded instance of T.

Identifier.path must be compatible with the fileResolver. Loading parameters are optional and can be used to configure the loaded asset.

Might throw the following exceptions:

If the asset was already loaded, added or scheduled for loading, this method will not fail or throw an exception (unless the original loading fails). Instead, the coroutine will be suspended until the original loading is finished and then return the same result.

Note that to unload an asset, unload method should be called the same amount of times as load. Asset dependencies should not be unloaded directly; instead, unload the asset that required them and caused them to load in the first place.

If the parameters define a AssetLoaderParameters.loadedCallback, it will be invoked on the main rendering thread after the asset is loaded successfully with this AssetStorage wrapped as an AssetManager with AssetManagerWrapper. Note that the wrapper supports a limited number of methods. It is encouraged not to rely on AssetLoaderParameters.LoadedCallback and use coroutines instead. Exceptions thrown by callbacks will not be propagated, and will be logged with logger instead.


suspend fun <T> load(descriptor: AssetDescriptor<T>): T

Schedules loading of an asset of T type described by the descriptor. Suspends the coroutine until an asset is loaded and returns a fully loaded instance of T.

Might throw the following exceptions:

If the asset was already loaded, added or scheduled for loading, this method will not fail or throw an exception (unless the original loading fails). Instead, the coroutine will be suspended until the original loading is finished and then return the same result.

Note that to unload an asset, unload method should be called the same amount of times as load. Asset dependencies should not be unloaded directly; instead, unload the asset that required them and caused them to load in the first place.

If the AssetDescriptor.params define a AssetLoaderParameters.loadedCallback, it will be invoked on the main rendering thread after the asset is loaded successfully with this AssetStorage wrapped as an AssetManager with AssetManagerWrapper. Note that the wrapper supports a limited number of methods. It is encouraged not to rely on AssetLoaderParameters.LoadedCallback and use coroutines instead. Exceptions thrown by callbacks will not be propagated, and will be logged with logger instead.