Skip to content

Assets from relative paths outside the asset folder not loading #21875

@DGriffin91

Description

@DGriffin91

Bevy version 0.17.3

Tested on Arch Linux

Works in 0.17.2 but not in 0.17.3. Likely from this PR: #21643

This has the flight helmet gLTF in both:
temp/asset_load_test/assets/FlightHelmet/FlightHelmet.gltf
and
temp/FlightHelmet/FlightHelmet.gltf

Both load and are seen on screen in 0.17.2, but only the left one in 0.17.3.

0.17.3 error:
ERROR bevy_asset::server: Failed to load asset '../../FlightHelmet/FlightHelmet.gltf' with asset loader 'bevy_gltf::loader::GltfLoader': failed to read bytes from an asset path: Path not found: /temp/asset_load_test/assets/FlightHelmet/FlightHelmet.bin

use bevy::{asset::UnapprovedPathMode, prelude::*};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(AssetPlugin {
            unapproved_path_mode: UnapprovedPathMode::Allow,
            ..default()
        }))
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.spawn((
        Camera3d::default(),
        Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
    ));

    commands.spawn((DirectionalLight {
        shadows_enabled: true,
        ..default()
    },));

    commands.spawn((
        SceneRoot(
            asset_server
                .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")),
        ),
        Transform::from_xyz(-1.0, 0.0, 0.0),
    ));

    commands.spawn((
        SceneRoot(
            asset_server
                .load(GltfAssetLabel::Scene(0).from_asset("../../FlightHelmet/FlightHelmet.gltf")),
        ),
        Transform::from_xyz(0.0, 0.0, 0.0),
    ));
}

Metadata

Metadata

Assignees

Labels

A-AssetsLoad files from disk to use for things like images, models, and soundsC-BugAn unexpected or incorrect behaviorP-RegressionFunctionality that used to work but no longer does. Add a test for this!S-Needs-DesignThis issue requires design work to think about how it would best be accomplished

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions