Can't deserialize tuple struct
rapushka opened this issue · 0 comments
rapushka commented
Steps to reproduce
- define a component with tuple struct
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct SpawnPoint(u8);
- default setup for this workflow (i use this one)
app
.register_type::<SpawnPoint>()
.add_plugins((ExportRegistryPlugin::default(), ComponentsFromGltfPlugin::default()))
// etc
- create blender file, connect registry, and add
SpawnPoint
component - export gltf (i exported with default gltf exporter, cuz i didn't managed to make auto_importer work tbh)
- in gltf file you can find
"SpawnPoint" : "(10)"
- if now try to run the game and load this gltf - it'll panic:
thread 'main' panicked at /home/rapuska/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_gltf_components-0.5.1/src/ronstring_to_reflect_component.rs:50:71:
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }
Workarounds
- remove parentheses, and just leave
"SpawnPoint" : "10"
in the.gltf
file
or - just use fields
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct SpawnPoint {
value: u8,
}
then in .gltf
it'll be serialized like "SpawnPoint" : "(value: 10)"
and work fine