Description
Bevy version
0.10.1
What you did
- Created fresh bevy project
- Made this main.rs file:
use bevy::prelude::*;
fn main() {
App::new()
.add_startup_system(start_up)
.add_system(serialize_scene_system)
.add_plugins(DefaultPlugins)
.run();
}
fn start_up(mut commands: Commands) {
// comment out this line to fix issue
commands.spawn(Camera2dBundle::default());
}
fn serialize_scene_system(world: &mut World) {
let type_registry = world.resource::<AppTypeRegistry>();
let scene = DynamicScene::from_world(world, type_registry);
let serialized_scene = scene.serialize_ron(type_registry).unwrap();
info!("{}", serialized_scene);
}
- Executed "cargo run"
What went wrong
I was expecting it to just serialize the world, as I have not really added any new code (i.e components/resources).
Instead, I got this error: thread 'main' panicked at 'called Result::unwrap()
on an Err
value: Message("no registration found for dynamic type with name bevy_math::rect::Rect")', src\main.rs:19:63
Additional information
It feels like something wasn't registered by bevy. If you comment out the line of code inside of start_up, which spawns the Camera bundle, the error disappears and program runs as expected.
My thoughts moving forward
I understand that in the examples, you usually create an empty world and throw in the things you want to save in the scene, or use the DynamicSceneBuilder. This may or may not be a common practice in the bevy community. But I think if you want to serialize the entire world, then you should be able to without bevy holding you back.
If we're in agreement, then we should make a unit test that ensures that a basic bevy setup always registers what is needed so that the entire World can be serialized. I would make a PR of this myself, and I would actually like to in order to have a contribution under my belt (perhaps the first of many), but I'm not familiar enough with Bevy to make a comprehensive unit test. So if someone could help me out with that, or if you just wanna leave suggestions here on what I should include in the unit test, I'd appreciate it!