Reflect derived traits on all components and resources: bevy_input (#15220)

Solves https://github.com/bevyengine/bevy/issues/15187 for bevy_input
This commit is contained in:
Blazepaws 2024-09-15 17:08:46 +02:00 committed by GitHub
parent 569f68f8a0
commit e718bbd55c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -1,5 +1,7 @@
//! The generic input type.
#[cfg(feature = "bevy_reflect")]
use bevy_ecs::reflect::ReflectResource;
use bevy_ecs::system::Resource;
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
@ -154,7 +156,7 @@ use std::hash::Hash;
///[`ResMut`]: bevy_ecs::system::ResMut
///[`DetectChangesMut::bypass_change_detection`]: bevy_ecs::change_detection::DetectChangesMut::bypass_change_detection
#[derive(Debug, Clone, Resource)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Default))]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Default, Resource))]
pub struct ButtonInput<T: Copy + Eq + Hash + Send + Sync + 'static> {
/// A collection of every button that is currently being pressed.
pressed: HashSet<T>,

View file

@ -2,6 +2,8 @@
use crate::{Axis, ButtonInput, ButtonState};
use bevy_ecs::event::{Event, EventReader, EventWriter};
#[cfg(feature = "bevy_reflect")]
use bevy_ecs::reflect::ReflectResource;
use bevy_ecs::{
change_detection::DetectChangesMut,
system::{Res, ResMut, Resource},
@ -384,7 +386,11 @@ impl GamepadAxis {
/// should register as a [`GamepadEvent`]. Events that don't meet the change thresholds defined in [`GamepadSettings`]
/// will not register. To modify these settings, mutate the corresponding resource.
#[derive(Resource, Default, Debug)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, Default))]
#[cfg_attr(
feature = "bevy_reflect",
derive(Reflect),
reflect(Debug, Default, Resource)
)]
pub struct GamepadSettings {
/// The default button settings.