-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Panic on Loading Asset from Absolute Path #11271
Comments
After looking at the line number from the panic message, I believe it is raised in bevy/crates/bevy_asset/src/path.rs Lines 138 to 150 in 4778fbe
My guess is that the code does not like the |
So after some testing, absolute paths still seem to work on Unix-based systems, just not Windows. use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
commands.spawn(SpriteBundle {
texture: asset_server.load("/Users/bd103/Downloads/random_image.png"),
..default()
});
} I think an important to ask is whether you should load absolute paths outside of the On the other hand, Bevy doesn't really provide any other good way to load user-provided paths (such as through drag-and-drop). It seems to shame to have to manually call Edit: After talking on Discord, it seems like maybe a custom asset source should be created for paths outside of the |
Bevy version
0.12.1
Also tested on commit hash: 41c3620
Relevant system information
Dell Precision 7670
Windows 11 Enterprise (10.0.22621 Build 22621)
What you did
I've been trying to load assets from absolute file paths (I'm making a small GLTF viewer which does not come pre-packaged with its models). Loading with asset_server.load() (where asset_server is Res) worked okay in Bevy 0.11 but in 0.12 I hit problems.
For example:
I also tested this against absolute paths provided from drag-and-drop events.
What went wrong
I expected the two load() lines above to be equivalent, but if I use the one with the absolute path I get the following error and my application panics:
I don't see anything about this specifically in the migration guide, so I'm assuming this is not expected behaviour.
Additional information
I was able to work around this issue by using the pathdiff crate to convert the absolute path into one which is relative to the current working directory. With this work-around it seems I'm able to load assets from anywhere on the system, confirming for me that issue above is not an access one.
The text was updated successfully, but these errors were encountered: