-
Notifications
You must be signed in to change notification settings - Fork 56
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 Support for Dynamic Asset Collections #198
Add Support for Dynamic Asset Collections #198
Conversation
Thanks for offering your solution 🙂 |
Hey, indeed #151 seems like a more general solution. Curious to know the reasons behind opting for not allowing single collections and multi collections in the same schema. I'm happy with this being a temp solution til we reach there, but I'm also ok with this not being merged (I can use my temp branch til we got #151 merged). I was just aiming to share this since it's quite a effortless/clean work around for the time being - also, it's cleaner than doing it downstream, since that in a downstream application using your lib one would need to create a wrapper struct just for that, instead of implementing DynamicAsset to Vec<_> directly. Thanks for the inputs. 😄 |
I meant this PR doesn't allow it, because a single file will be loaded as |
531d626
to
d9b09db
Compare
@NiklasEi I finally had some time to add documentation and tests. Please let me know if you want me to add anything else before merging this PR. |
f840ae7
to
4fb0965
Compare
Ok, there was some flakiness in the test due to the nature of RON serialization/deserialization (it doesn't guarantee the order of the elements). I changed it to compare before/after deserialized objects instead of the RON strings, it should be fine now. |
4fb0965
to
9888663
Compare
Hi @NiklasEi is there anything else I can do to help getting this merged? Let me know if I can help 😄 |
Thank you 🙂 |
This PR introduces the ability to load and build collections of dynamic assets in bevy_asset_loader, addressing the need outlined in issue #186. The enhancement allows for more flexible asset management, enabling users to define and group dynamic assets in structured collections.
Motivation
Previously, loading multiple dynamic assets required individual handling for each asset, complicating the asset loading process and cluttering the codebase. With this update, users can now group related assets together, simplifying the loading process (specially for applications that handles a huge number of assets dynamically).
Changes
DynamicAsset Trait for Vec: Implemented the DynamicAsset trait for Vec, enabling the loading and building of asset collections.
StandardDynamicAssetArrayCollection: Introduced a new struct to represent collections of dynamic assets, allowing assets to be grouped and registered under a common key.
Usage Example
With these changes, users can now define array of asset collections in RON format:
And the rust code would look like:
Conclusion
This update offers a straightforward method for managing multiple dynamic assets within the bevy_asset_loader. It's particularly beneficial for applications dealing with a large number of assets dynamically, aiming to simplify the process and improve developer experience. By grouping assets into collections, it hopes to make dynamic asset handling more accessible and less cumbersome.