Typed alternative to `load_folder`
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
For my game I'm loading a single file with two different asset loaders, each producing a separate asset. One asset is a `BlockDefinition` which will contain all properties necessary to simulate the block, such as its collision shape and behavior. The other asset is a `BlockVisuals` which holds all that is necessary to display the block, such as mesh, texture and material. The latter would not be loaded on a headless server.
I want to be able to hot reload these assets including adding and removing them on the fly for ease of development or modding.
## What solution would you like?
It would be nice to have a typed alternative to `load_folder` that allows me to specify what type of asset I want to load. Since this API will decide what type of asset to load a file as depending on the extension, I won't ever be able to load a single `.ron` file as two separate types of assets using it.
## What alternative(s) have you considered?
- Hardcode the asset paths instead.
- Use a manifest file which mentions all the other files that need to load. [Necessary on web anyway?](https://github.com/bevyengine/bevy/issues/10459)
- Split the file into two, with different extensions, so `load_folder` can handle them.
- Register only a single asset loader, but a different one depending on whether on headless or client, which can then load `BlockDefinition` and `BlockVisuals` as sub-assets/dependencies from the single file with the right type explicitly, and use asset events to collect them into resources? Seems a bit over-engineered.
## Additional context
Source code of the project available to browse [here](https://git.mcft.net/copygirl/bevy-bloxel-classic).
## Related issues / pull requests
- #19760 has the same issue. But a typed version of it would be nice.
- #11061 mentions how it's no longer possible to access directories. (Though unsure how this would work with hot reloading.)
- #2291 – OP mentions a typed API, but commenters ended up talking about filtering paths only.
Contributor guide
Research direction
Start with the existing `load_folder` API and compare the related discussions in issues #19760, #11061, and #2291. Define the typed loading behavior, including extension-based type selection and hot reloading, then confirm the API handles the stated single-file and headless-server use cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100