kaosat-dev / Blenvy

Bevy Code & Blender addon for a simple workflow to add & edit Bevy components in Blender

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't deserialize tuple struct

rapushka opened this issue · comments

Steps to reproduce

  1. define a component with tuple struct
#[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)]
pub struct SpawnPoint(u8);
  1. default setup for this workflow (i use this one)
app
    .register_type::<SpawnPoint>()
    .add_plugins((ExportRegistryPlugin::default(), ComponentsFromGltfPlugin::default()))
// etc
  1. create blender file, connect registry, and add SpawnPoint component
  2. export gltf (i exported with default gltf exporter, cuz i didn't managed to make auto_importer work tbh)
  3. in gltf file you can find "SpawnPoint" : "(10)"
  4. 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