Skip to content

Scene not loading when entity has GlobalTransform or Children #6573

@ShinySapphic

Description

@ShinySapphic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ReflectionRuntime information about typesA-ScenesSerialized ECS data stored on the diskC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions