bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Scene not loading when entity has GlobalTransform or Children

Open ShinySapphic opened this issue 3 years ago • 1 comments

Bevy version

0.9.0

What you did

I attempted to save and load a scene

fn load_scene(
    mut commands: Commands,
    assets: Res<AssetServer>,
) {
    commands.spawn(DynamicSceneBundle {
        scene: assets.load("scenes/test.scn.ron"),
        ..default()
    });
}

fn save_scene(world: &mut World) {
    for entity in world
        .query_filtered::<Entity, With<Camera>>()
        .iter(world)
        .collect::<HashSet<_>>()
    {
        world.despawn(entity);
    }

    let type_registry = world.resource::<AppTypeRegistry>();
    let scene = DynamicScene::from_world(world, type_registry);

    let serialized = scene
        .serialize_ron(type_registry)
        .expect("Failed to serialize the world");

    #[cfg(not(target_arch = "wasm32"))]
    IoTaskPool::get()
        .spawn(async move {
            fs::write("assets/scenes/test.scn.ron", serialized.as_bytes())
                .expect("Failed to write to file");
        })
        .detach();
}

What went wrong

Scene does not load and logs a message to the console.

Additional information

Logs

When an entity is saved with a GlobalTransform component

WARN bevy_asset::asset_server: encountered an error while loading an asset: Expected float

When loading a scene with an entity that has children.

WARN bevy_asset::asset_server: encountered an error while loading an asset: no registration found for type `smallvec::SmallVec<[bevy_ecs::entity::Entity; 8]>`

Removing both components from the ron file allows the scene to load. Obviously doing so might cause weird behaviors since entities don't have any of these components anymore.

ShinySapphic avatar Nov 13 '22 01:11 ShinySapphic

Can confirm, have the same problem. ^^"

Edit: Seems like that the problem is from parsing the Ron file (inside the library), maybe because it's a tuple? ^^"

kerkmann avatar Nov 13 '22 22:11 kerkmann

Closing as this should be resolved by #6578 and #6580, which should both be out now in v0.9.1 which was recently released.

If you notice it's still broken, feel free to reopen!

MrGVSV avatar Dec 03 '22 07:12 MrGVSV