Interface AsyncAssetLoadingFragment
- All Superinterfaces:
Fragment
A fragment that can load assets asynchronously using the provided AssetManager. This is useful for
components that need to load assets without blocking the main thread.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
loadAssetsAsync
(ComponentManager mng, AsyncAssetManager assetManager, DataStore assetCache, Consumer<Object> preload) This method is called from the asset loader thread and can be used to load and transform assets asynchronously, without blocking the main thread.
-
Method Details
-
loadAssetsAsync
void loadAssetsAsync(ComponentManager mng, AsyncAssetManager assetManager, DataStore assetCache, Consumer<Object> preload) This method is called from the asset loader thread and can be used to load and transform assets asynchronously, without blocking the main thread. A component implementing this fragment will stay in "pending" state until theinvalid reference
#loadAssetsAsync(AsyncAssetManager)
Thread Safety Warning: This method executes on a background thread. You must not modify the scene graph or access other thread-unsafe objects from this method. Instead, as a rule of thumb, you should only load assets here and pass them to the
Component.onEnable(org.ngengine.components.ComponentManager, org.ngengine.components.Runner, org.ngengine.components.DataStoreProvider, boolean, Object)
method using class fields.- Parameters:
mng
- the ComponentManager instanceassetManager
- the AsyncAssetManager instance to use for loading assetsassetCache
- the DataStore instance to use for caching loaded assetspreload
- a consumer that can be called for each assets to preload. It will start uploading the asset to the gpu as soon as possible.
-