Open
Description
Bevy version
git main branch
What you did
Example code:
use bevy::{
reflect::{DynamicStruct, ReflectFromReflect, TypeRegistry},
render::camera::Camera,
};
fn main() {
let mut type_registry = TypeRegistry::default();
type_registry.register::<Camera>();
let rfr = type_registry
.get_type_data::<ReflectFromReflect>(std::any::TypeId::of::<Camera>())
.unwrap();
let mut dyn_struct = DynamicStruct::default();
dyn_struct.insert("order", 4isize);
let camera = rfr.from_reflect(&dyn_struct).unwrap();
let camera = camera.downcast_ref::<Camera>().unwrap();
assert_eq!(camera.order, 4);
eprintln!("Assert with isize passed");
let mut dyn_struct = DynamicStruct::default();
dyn_struct.insert("order", 4i64);
let camera = rfr.from_reflect(&dyn_struct).unwrap();
let camera = camera.downcast_ref::<Camera>().unwrap();
assert_eq!(camera.order, 4);
eprintln!("Assert with i64 passed");
}
What went wrong
Output:
Assert with isize passed
thread 'main' panicked at src/main.rs:26:5:
assertion `left == right` failed
left: 0
right: 4
I assume that the same issue exists for usize/u64, but I haven't actually checked. I also don't think that this is related to the Camera component specifically, I just ran into the problem with that component.
Additional information
I'm very well aware that isize
is not i64
, but for all purposes, it is equivalent on 64 bit machines. I don't think that many scripting languages can differentiate between these two types, so not autoconverting makes the whole thing unnecessarily complicated for a lot of use cases.