Interface AsyncAssetLoadingFragment

All Superinterfaces:
Fragment

public interface AsyncAssetLoadingFragment extends 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 Type
    Method
    Description
    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.
  • 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 the
      invalid reference
      #loadAssetsAsync(AsyncAssetManager)
      method completes its execution and they are subsequently enabled by the component manager.

      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 instance
      assetManager - the AsyncAssetManager instance to use for loading assets
      assetCache - the DataStore instance to use for caching loaded assets
      preload - a consumer that can be called for each assets to preload. It will start uploading the asset to the gpu as soon as possible.