diff --git a/crates/bevy_picking_core/src/backend.rs b/crates/bevy_picking_core/src/backend.rs index fe4b910c..e07ab77f 100644 --- a/crates/bevy_picking_core/src/backend.rs +++ b/crates/bevy_picking_core/src/backend.rs @@ -167,7 +167,8 @@ pub mod ray { /// } /// } /// ``` - #[derive(Clone, Debug, Default, Resource)] + #[derive(Clone, Debug, Default, Resource, Reflect)] + #[reflect(Resource)] pub struct RayMap { map: HashMap, } diff --git a/crates/bevy_picking_core/src/events.rs b/crates/bevy_picking_core/src/events.rs index 33c394c2..1114dbf3 100644 --- a/crates/bevy_picking_core/src/events.rs +++ b/crates/bevy_picking_core/src/events.rs @@ -342,11 +342,12 @@ pub fn pointer_events( } /// Maps pointers to the entities they are dragging. -#[derive(Debug, Deref, DerefMut, Default, Resource)] +#[derive(Debug, Deref, DerefMut, Default, Resource, Reflect)] +#[reflect(Resource)] pub struct DragMap(pub HashMap<(PointerId, PointerButton), HashMap>); /// An entry in the [`DragMap`]. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Reflect)] pub struct DragEntry { /// The position of the pointer at drag start. pub start_pos: Vec2, diff --git a/crates/bevy_picking_core/src/focus.rs b/crates/bevy_picking_core/src/focus.rs index 9d32701b..ae2e1f9f 100644 --- a/crates/bevy_picking_core/src/focus.rs +++ b/crates/bevy_picking_core/src/focus.rs @@ -49,11 +49,13 @@ type OverMap = HashMap; /// this authoritative hover state, and you can do the same. You can also use the /// [`PreviousHoverMap`] as a robust way of determining changes in hover state from the previous /// update. -#[derive(Debug, Deref, DerefMut, Default, Resource)] +#[derive(Debug, Deref, DerefMut, Default, Resource, Reflect)] +#[reflect(Resource)] pub struct HoverMap(pub HashMap>); /// The previous state of the hover map, used to track changes to hover state. -#[derive(Debug, Deref, DerefMut, Default, Resource)] +#[derive(Debug, Deref, DerefMut, Default, Resource, Reflect)] +#[reflect(Resource)] pub struct PreviousHoverMap(pub HashMap>); /// Coalesces all data from inputs and backends to generate a map of the currently hovered entities. diff --git a/crates/bevy_picking_core/src/lib.rs b/crates/bevy_picking_core/src/lib.rs index 0f3bce8f..5dfe8f4e 100644 --- a/crates/bevy_picking_core/src/lib.rs +++ b/crates/bevy_picking_core/src/lib.rs @@ -14,6 +14,7 @@ use bevy_ecs::prelude::*; use bevy_reflect::prelude::*; use bevy_eventlistener::{prelude::*, EventListenerSet}; +use focus::{HoverMap, PreviousHoverMap}; /// Used to globally toggle picking features at runtime. #[derive(Clone, Debug, Resource, Reflect)] #[reflect(Resource, Default)] @@ -208,11 +209,14 @@ impl Plugin for CorePlugin { ) .register_type::() .register_type::() + .register_type::() .register_type::() .register_type::() + .register_type::() .register_type::() .register_type::() - .register_type::(); + .register_type::() + .register_type::(); } } @@ -253,6 +257,9 @@ impl Plugin for InteractionPlugin { EventListenerPlugin::>::default(), EventListenerPlugin::>::default(), EventListenerPlugin::>::default(), - )); + )) + .register_type::() + .register_type::() + .register_type::(); } } diff --git a/crates/bevy_picking_core/src/pointer.rs b/crates/bevy_picking_core/src/pointer.rs index 6804f7dd..4cc24b9d 100644 --- a/crates/bevy_picking_core/src/pointer.rs +++ b/crates/bevy_picking_core/src/pointer.rs @@ -77,7 +77,8 @@ impl Deref for PointerInteraction { } /// A resource that maps each [`PointerId`] to their [`Entity`] for easy lookups. -#[derive(Debug, Clone, Default, Resource)] +#[derive(Debug, Clone, Default, Resource, Reflect)] +#[reflect(Resource)] pub struct PointerMap { inner: HashMap, } @@ -225,7 +226,6 @@ impl PointerButton { pub struct PointerLocation { /// The [`Location`] of the pointer. Note that a location is both the target, and the position /// on the target. - #[reflect(ignore)] pub location: Option, } impl PointerLocation { @@ -280,6 +280,7 @@ impl InputMove { /// render target. It is up to picking backends to associate a Pointer's `Location` with a /// specific `Camera`, if any. #[derive(Debug, Clone, Component, Reflect, PartialEq)] +#[reflect(Component)] pub struct Location { /// The [`NormalizedRenderTarget`] associated with the pointer, usually a window. pub target: NormalizedRenderTarget,