#[derive(Component)]
{
// Attributes available to this derive:
#[component]
}
Expand description
A derive macro that implements the khora_data::ecs::Component trait
and generates a serializable mirror struct with From conversions.
For a component like:
ⓘ
#[derive(Component)]
pub struct Camera {
pub projection: ProjectionType,
pub aspect_ratio: f32,
}This macro generates:
impl Component for Camerapub struct SerializableCamera { ... }withEncode, Decodeimpl From<Camera> for SerializableCameraimpl From<SerializableCamera> for Camera
Use #[component(skip)] on fields that should not be serialized
(e.g., GPU handles). Those fields are filled with Default::default()
when deserializing back.