NiklasEi / bevy_asset_loader

Bevy plugin helping with asset loading and organization
Apache License 2.0
474 stars 52 forks source link

Need to use handles from collection during loading state #77

Closed inodentry closed 1 year ago

inodentry commented 2 years ago

I'd like to set up a loading screen with a progress indicator that shows the percentage ready.

However, to spawn the UI with the Text for the percentage indicator, I need a Handle to my Font.

bevy_asset_loader only inserts the AssetCollection when those assets have actually been loaded, meaning it is not available for me to access when entering the loading state, to set up my UI.

Is it possible to make an AssetCollection available from the start? The only way I see is from the example without using a loading state. However, I want to use a loading state. I just want to be able to use the handles when entering it.

It's okay if the handles point to assets that aren't loaded yet. I just need to setup my loading/splash screen. The UI will just "pop in" when those specific assets become available.

NiklasEi commented 2 years ago

What you describe should be doable by using init_collection on App for the collection that you want to access directly. This will however give you no guarantees about when the handles are loaded (I understand that's what you want here).

I would propose a different option: have a minimal loading state without loading screen. In that state you load only assets needed for the loading screen itself so it should be very fast. Then continue to the loading screen and show the progress UI from the beginning.

NiklasEi commented 2 years ago

In case you want to go with the init_collection solution: You should be able to also track the collection you initialized, by adding it to the loading state as well as calling init_collection for it.

NiklasEi commented 1 year ago

I would close this for now as you can do this with init_collection as long as the assets are "simple", as in loaded directly and do not require post-processing (no dynamic assets, standard materials and so on).