#Basic scene serialization crashing

30 messages · Page 1 of 1 (latest)

celest flare
#

I have a system:

fn beep(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);
}

Which works fine. Then when i add this:

fn start_up(mut commands: Commands, mut clear_color: ResMut<ClearColor>) {
    commands.spawn(Camera2dBundle::default());
    clear_color.0 = Color::BLACK;
}

I get a crash: "no registration found for dynamic type with name bevy_math::rect::Rect". If i comment out the line where im spawning the camera, it works again.

Whats going on here? I'm feeling very dumb atm.

Also, if i dont want the whole world, do i just query for the entities and resources that i want, place them in an empty world, then serialize that instead?

And another thing...It appears the example in the git repo doesnt even serialize or save the resource? I would very much like to do that, please.

red plume
#

From the error, it seems a registration is missing. You can add it yourself by registering Rect, but realistically Bevy should be registering its own types for you, so please file an issue/PR

#

And if you don’t want the whole world, check out DynamicSceneBuilder which lets you query for specific entities

celest flare
celest flare
red plume
#

Also, did you add #[reflect(Resource)] on the resource type definition?

red plume
#

Oh my apologies

#

Resource extraction is not released yet it seems. I guess it’s a 0.11 thing, which means it’ll be available on crates.io very soon

celest flare
red plume
#

It still probably won’t work

#

Yeah sorry for the confusion haha

celest flare
#

mhm, yes can confirm doesnt work lol

red plume
#

It exists on main just not latest

celest flare
#

so like, up until this point, ppl haven't been able to save resources into scenes?

red plume
#

I guess not haha

celest flare
#

My goodness

red plume
#

You could hack it together by using a resource-like component

#

But for your case I’d just wait

#

It’s supposedly going to be released this weekend

celest flare
#

Yeah it just made sense to make a it a resource, since its a global setting thing. But if its that close then i can wait until 0.11 is out. Thanks for the help!

red plume
#

No problem!

#

If you want, you could also start targeting main

#

Then just switch to 0.11 on release

celest flare
celest flare
red plume