Closed AntonZelenin closed 11 months ago
Unfortunately with bevy_reflect, you need to manually monomorphize and register generic types. Bevy does this for a few types (i.e. Option<String>
) but you have to do the same with your own types (until something like https://github.com/bevyengine/bevy/pull/5781 is merged).
So in your case,you could do
app.register_type::<Option<Direction>>();
[!note] If the derive macro doesn't automatically pick up your
Option
, you can add#[schematic(optional)]
to your field.
Unfortunately with bevy_reflect, you need to manually monomorphize and register generic types. Bevy does this for a few types (i.e.
Option<String>
) but you have to do the same with your own types (until something like bevyengine/bevy#5781 is merged).So in your case,you could do
app.register_type::<Option<Direction>>();
Note If the derive macro doesn't automatically pick up your
Option
, you can add#[schematic(optional)]
to your field.
Oh, great, it works! Thank you :)
I'm trying to use a couple of components:
but I get an error from proto
no registration found for type core::option::Option<expeditions::core::controls::components::Direction>
when I try to spawn a player that has MovementDirection. How can I use a component with another component that is optional? It is working with standard types like String, but not with my components.