ManagedAsset

class ManagedAsset<Type>(val manager: AssetManager, val assetDescriptor: AssetDescriptor<Type>) : Asset<Type>

Default implementation of Asset. Keeps asset data in an AssetDescriptor and delegates asset loading to an AssetManager. Assumes the asset was already scheduled for loading.

Constructors

Link copied to clipboard
constructor(manager: AssetManager, assetDescriptor: AssetDescriptor<Type>)

Properties

Link copied to clipboard
open override val asset: Type

Instance of the wrapped asset. Might not be loaded yet. Calling getter of this property without making sure that the asset is loaded might cause an exception.

Link copied to clipboard

The AssetDescriptor used by AssetManager to identify and load the asset.

Link copied to clipboard

Functions

Link copied to clipboard
open override fun finishLoading()

Forces eager loading of the asset. Note that due to AssetManager implementation, eager asset loading causes all scheduled assets to be loaded synchronously until the desired asset is reported as loaded. It is usually sensible to use a separate AssetManager for eagerly loaded assets or load such assets after all regular assets are already loaded.

Link copied to clipboard
inline operator fun <Type> Asset<Type>.getValue(receiver: Any?, property: KProperty<*>): Type

Extension function that allows Asset instances to be delegates using the "by" keyword.

Link copied to clipboard
open override fun isLoaded(): Boolean
Link copied to clipboard
open override fun load()

Explicitly marks that the asset should be loaded. If this asset is managed by an AssetManager instance, will schedule asset loading.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun unload()

Attempts to unload the asset. Might throw an exception if the asset is not loaded at all due to AssetManager implementation.