Closed Troels51 closed 2 years ago
Yes. Folders do not work on the web. Usually, websites do not offer the possibility to get all content under a certain path. If you want to support web, you will have to load your asset files from full paths.
See bevyengine/bevy#2916
It seems related to this issue on bevy itself https://github.com/bevyengine/bevy/issues/2916
I see we found the same issue. I will have to figure out a way to get around this because it would be nice to easily add new hexes without having to recompile.
I see we found the same issue. I will have to figure out a way to get around this because it would be nice to easily add new hexes without having to recompile.
I guess this could be solved by supporting more ways to load folders in dynamic asset collections?
For example, I could add support for listing files to be loaded as a Vec<Handle<T>>
:
({
"hexes": Folder (
paths: [
"images/hex_1.png",
"images/hex_2.png",
"images/hex_3.png",
"images/hex_4.png",
"images/hex_5.png"
],
),
})
In you code:
#[derive(AssetCollection)]
struct ImageAssets {
#[asset(key = "hexes", folder(typed))]
hexes: Vec<Handle<Image>>,
}
Would that help? That should work on the web and not require a recompile when adding new file paths.
That would be a good tool to have. Then a new hex can be added by adding the asset and updating the index file
I was thinking I could use trunk.rs to generate the file list as part of the web build. Then I wouldn't have to maintain that file as well.
I see you implemented the change. I really appreciate that, and thanks for the hard work 🙂
I am having trouble getting a folder loaded when running on the web. I am using your template for building and deploying my stuff to github pages, but a folder that is loading fine on windows is panicking on the web.
You should see the problem on this deployment: (https://troels51.github.io/hex_map_bevy/) And it is panicking like this in the log
panicked at 'called `Result::unwrap()` on an `Err` value: AssetFolderNotADirectory("hexes")', src\loading\hex.rs:20:10