bevyengine / bevyengine/bevy

`load_folder()` only on some `Asset` types/extensions

Open
#2,291 8 comments 1 reaction 0 assignees View on GitHub
A-Assets C-Feature D-Modest S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?
I would like to be able to `load_folder()` on files with only particular extensions,

My game's assets folder would be something like this:
```
assets
mods
[mod_name]
data
events
localization
scripts
[mod_name]
data
events
localization
scripts
```
and such.

As far as I understand it, it would be hard to traverse the assets folder with `std::fs` on certain platforms,
so i was suggested to just `load_folder("/mods")`
but that would raise the issues:
1) My game might do work that I don't actually want to do at that point(loading assets this system/plugin doesn't care about)
2) I would need to iterate on all assets of some type, clone their handles, and then remove the resource of the `Vec` i got from `load_folder` which is not super nice API-wise. (on this part I'm not sure, if there's a way to turn a `HandleUntyped` to a type of `Handle` without this, i'm sorry).
3) (I'm not sure it's possible) but I might somehow break other plugins I depend on, for example, `bevy_fluent`'s files would be inside every mod's localization folder

## What solution would you like?
It will probably be hard to associate an asset type(for example `Texture`) with the extensions it might consist of) so it won't be easy to get `Vec>` out of `load_folder::("path")` although it would be preferable,

So I'd be fine if we would keep returning a `Vec` but `load_folder` (or a different function) would take an extensions array and only load files with those extensions.

## What alternative(s) have you considered?
only the 2 above for now.

## Additional context
none for now.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.