#Reading/Writing Assets anywhere in the filesystem (outside project dir)?

1 messages · Page 1 of 1 (latest)

covert glen
#

My users want to be able to customize the folder that their saves go in.
I've been handling file saving/loading manually so far, but I'd like to use the bevy Asset Server if possible.

From what I've been reading I probably should register a custom AssetSource that is set to the root directory (users are on Windows, so usually "C") of the user's file directory, and then I can just specify the full path to each asset when I load/save.

However I'm not sure how to do that... can't find any examples and Discord search doesn't yield anything either. Any help would be greatly appreciated!

covert glen
#

Hmmm, looks like the Asset Server is just made for reading, not writing (its in the name, in hindsight, lol). So I'll keep my existing approach to saving.

covert glen
#

Keeping this issue open because I still haven't been able to figure out how to LOAD scenes using the asset server when they are stored outside the project directory, the asset server just silently fails.

sour pebble
#

There's something called the UnapprovedPathMode which will prevent loading files outside your assets folder by default

covert glen
#

I figured it out, it does silently fail, but if you add this, from the bottom of the official example (even though it confusingly says its probably not something you want to add to your own app, lol) then it panics: /// To help with Bevy's automated testing, we want the example to close with an appropriate if the /// scene fails to load. This is most likely not something you want in your own app. fn panic_on_fail(scenes: Query<&DynamicSceneRoot>, asset_server: Res<AssetServer>) { for scene in &scenes { if let Some(LoadState::Failed(err)) = asset_server.get_load_state(&scene.0) { panic!("Failed to load scene. {err}"); } } }

#

Still haven't figured out loading assets from other parts of the file system, but now that I can see some error messages I should hopefully figure it out

sour pebble
#

Silently failing is obviously not a desirable outcome. Consider filing an issue with a minimal reproducible example! So hopefully we can fix it for the next person

covert glen
#

When trying to make reproducible example for an issue I discovered that if you enable the bevy_log feature then you do get this logged error : ERROR bevy_asset::server: Path not found:

sour pebble
#

Ohhhh hahaha yes that would do it