diff --git a/crates/bevy_core/src/lib.rs b/crates/bevy_core/src/lib.rs index 5c669186d7934..708b006d7d293 100644 --- a/crates/bevy_core/src/lib.rs +++ b/crates/bevy_core/src/lib.rs @@ -21,6 +21,7 @@ pub mod prelude { } use bevy_app::prelude::*; +use bevy_ecs::component::{ComponentId, ComponentTicks, Tick}; use bevy_ecs::prelude::*; use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; use bevy_utils::{Duration, HashSet, Instant, Uuid}; @@ -40,13 +41,21 @@ pub struct TypeRegistrationPlugin; impl Plugin for TypeRegistrationPlugin { fn build(&self, app: &mut App) { - app.register_type::().register_type::(); + app.register_type::(); + register_ecs_types(app); register_rust_types(app); register_math_types(app); } } +fn register_ecs_types(app: &mut App) { + app.register_type::() + .register_type::() + .register_type::() + .register_type::(); +} + fn register_rust_types(app: &mut App) { app.register_type::>() .register_type_data::, ReflectSerialize>() diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index e017ea4f5498a..cae48be957bd0 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -10,6 +10,8 @@ use crate::{ }; pub use bevy_ecs_macros::Component; use bevy_ptr::{OwningPtr, UnsafeCellDeref}; +#[cfg(feature = "bevy_reflect")] +use bevy_reflect::Reflect; use std::cell::UnsafeCell; use std::{ alloc::Layout, @@ -287,6 +289,11 @@ impl ComponentInfo { /// from a `World` using [`World::component_id()`] or via [`Components::component_id()`]. Access /// to the `ComponentId` for a [`Resource`] is available via [`Components::resource_id()`]. #[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)] +#[cfg_attr( + feature = "bevy_reflect", + derive(Reflect), + reflect(Debug, Hash, PartialEq) +)] pub struct ComponentId(usize); impl ComponentId { @@ -670,6 +677,7 @@ impl Components { /// A value that tracks when a system ran relative to other systems. /// This is used to power change detection. #[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, PartialEq))] pub struct Tick { tick: u32, } @@ -763,6 +771,7 @@ impl<'a> TickCells<'a> { /// Records when a component was added and when it was last mutably dereferenced (or added). #[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug))] pub struct ComponentTicks { pub(crate) added: Tick, pub(crate) changed: Tick,