bevy
bevy copied to clipboard
Implement various `Reflect` traits on `std` library types
Thanks so much for bevy
! Its an awesome crate and ecosystem that is awesome to program with :)
What problem does this solve or what need does it fill?
I am wanting to #[derive(Reflect)]
on structs / enums with std
library types, like IpAddr
, in the same way I can derive them for primitive types like u16
and bool
.
What solution would you like?
This code to just compile:
#[derive(bevy::prelude::Reflect)]
struct Foo {
bar: std::net::IpAddr,
bax: std::time::Duration,
}
So that I can do awesome things like:
app.register_type::<Foo>()
What alternative(s) have you considered?
I know no other way of actually being able to reflect these values, nor if it is even possible given that the fields are private. I do not want to resort to manually implementing TypePath
, Reflect
and FromReflect
for wrapper types and using those everywhere, since my lack of knowledge in this area is too big a blocker to spend a few days experimenting.
Additional context
This would allow me to edit std library types using bevy_editor_pls
no blockers here as i see. i think a PR reflecting most std
types (especially with reflect_value
) would be unambiguously approved - it's just churn. unfortunately considering there are a lot of types in std
it's unlikely we'll get around to many without a dedicated PR or an issue focused to a narrower set of types.