bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.71k stars 3.61k forks source link

Can't deserialize scene #9947

Open HaNaK0 opened 1 year ago

HaNaK0 commented 1 year ago

Bevy version

0.11.2 & 0.11.3

What you did

I have serialized a dynamic scene and now I try to desrialize it

What went wrong

I hope there to be entities loaded in preferably with sprites but the world is empty whcih i verify by serializing the scene again

Additional information

The warning I get is 2023-09-28T07:36:55.657629Z WARN bevy_asset::asset_server: encountered an error while loading an asset: no registration found for type `core::option::Option<glam::f32::vec2::Vec2>` at scenes/scene.scn:52:22

The part from scenes/scene.scn the warning is referencing Skärmbild 2023-09-28 094751

66OJ66 commented 1 year ago

In order to deserialize a scene, each of the types in that scene need to have been registered. Most Bevy types are registered automatically, but it looks like Option<Vec2>> isn't.

So to fix this, you just need to register that missing type in your app e.g.

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Include this
        .register_type::<Option<Vec2>>()
        .run();
}

Hope this helps!

HaNaK0 commented 1 year ago

Ok, so it's possible to register types you haven't created. But Option<Vec2>> maybe should be registered? Seems like a common usecase to store transforms.