AssetProvider

open class AssetProvider(val context: Context)

Provides helper functions to load and prepare assets without having to use null or lateinit.

Constructors

Link copied to clipboard
fun AssetProvider(context: Context)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
inline fun <T : Any> get(file: VfsFile): T
fun <T : Any> get(clazz: KClass<T>, vfsFile: VfsFile): T
Link copied to clipboard
inline fun <T : Any> load(file: VfsFile, parameters: GameAssetParameters = EmptyGameAssetParameter()): GameAsset<T>
fun <T : Any> load(file: VfsFile, clazz: KClass<T>, parameters: GameAssetParameters = EmptyGameAssetParameter()): GameAsset<T>

Loads an asset asynchronously.

Link copied to clipboard
inline suspend fun <T : Any> loadSuspending(file: VfsFile, parameters: GameAssetParameters = EmptyGameAssetParameter()): GameAsset<T>
suspend fun <T : Any> loadSuspending(file: VfsFile, clazz: KClass<T>, parameters: GameAssetParameters = EmptyGameAssetParameter()): GameAsset<T>

Loads an asset in a suspending function.

Link copied to clipboard
fun <T : Any> prepare(action: suspend () -> T): PreparableGameAsset<T>

Prepares a value once assets have finished loading. This acts the same as lazy except this will invoke the action once loading is finished to ensure everything is initialized before the first frame.

Link copied to clipboard
fun update()

Updates to check if all assets have been loaded, and if so, prepare them.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Calls update to get the latest assets loaded to determine if is has been fully loaded.

Link copied to clipboard
Link copied to clipboard
var onFullyLoaded: () -> Unit? = null
Link copied to clipboard
Link copied to clipboard
var prepared: Boolean = false

Holds the current state of assets being prepared.