Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependencies of assets to the list of watched assets for transition out of loading state #63

Closed
stinkytoe opened this issue Jun 25, 2022 · 5 comments

Comments

@stinkytoe
Copy link

Here's an example:
I use a custom loader for ldtk map files which loads and parses the ldtk file, and provides it as an asset to Bevy. I also load all of the images used for sprites/backgrounds/tiles/etc when I do this, and use the LoadedAsset::with_dependencies(...) member to add them as dependencies to my ldtk asset.

When I register this asset using an AssetCollection, as described in your readme, it seems to be correctly waiting on the ldtk file itself to load. However, it does not wait on all of the referenced images.

I will look at creating a dynamic asset description when constructing the asset, or simply adding the images separately. It would be a nice feature if your crate could detect this, however, due to the fact that the ldtk user could change what images they utilize at any time.

I don't know of other examples of assets with dependencies, but I imagine they could take advantage of this feature as well.

@stinkytoe stinkytoe changed the title Add dependencies of assets to the list of watched assets for state transition out of loading state Add dependencies of assets to the list of watched assets for transition out of loading state Jun 25, 2022
@NiklasEi
Copy link
Owner

NiklasEi commented Jul 3, 2022

It sounds very reasonable to wait for dependencies to load.

I shortly looked into this and it seems I do not have access to the dependencies where I would need to. The only place I could find that makes use of them is the asset server itself.

@stinkytoe
Copy link
Author

Honestly when compiled with --release there is very little time between when my custom ldtk loader finishes, and the images finish loading. In debug builds, it takes like five seconds though (on my system without dynamically linking bevy).

So I think it would be a great feature to have, and could also be argued to be the "correct" way. But, considering the unsupported and undocumented nature of custom asset loaders, I could totally understand if this was a low priority at this time.

Thanks for looking into it!

@NiklasEi
Copy link
Owner

In my opinion the priority is pretty high. There is just little I can do in the plugin itself, since Bevy does not expose the dependencies.

Without bevyengine/bevy#5297 I can only think of ugly workarounds, that would require the asset loaders to somehow tell bevy_asset_loader about their dependencies. And those wouldn't even work with "standard" loaders like Bevy's GLTF loader.

@NiklasEi
Copy link
Owner

This can be implemented as soon as bevyengine/bevy#8624 lands (Bevy 0.12 in around 3 months).

@NiklasEi
Copy link
Owner

The latest version waits until a handle and all it's dependencies are loaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants