Fix registering all reflection types that are components as reflection components (#16800)
# Objective Fixes #16659 ## Solution - I just added all the `#[reflect(Component)]` attributes where necessary. ## Testing I wrote a small program that scans the bevy code for all structs and enums that derive `Component` and `Reflect`, but don't have the attribute `#[reflect(Component)]`. I don't know if this testing program should be part of the testing suite of bevy. It takes a bit of time to scan the whole codebase. In any case, I've published it [here](https://github.com/anlumo/bevy-reflect-check). --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
parent
a656023363
commit
56688b387c
@ -3,7 +3,10 @@
|
||||
use core::ops::{Deref, DerefMut};
|
||||
|
||||
use bevy_asset::Handle;
|
||||
use bevy_ecs::component::{require, Component};
|
||||
use bevy_ecs::{
|
||||
component::{require, Component},
|
||||
reflect::ReflectComponent,
|
||||
};
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_transform::components::Transform;
|
||||
|
||||
@ -73,6 +76,7 @@ impl DerefMut for GizmoAsset {
|
||||
///
|
||||
/// [`Gizmos`]: crate::gizmos::Gizmos
|
||||
#[derive(Component, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[require(Transform)]
|
||||
pub struct Gizmo {
|
||||
/// The handle to the gizmo to draw.
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
use crate::{Axis, ButtonInput, ButtonState};
|
||||
use bevy_core::Name;
|
||||
#[cfg(feature = "bevy_reflect")]
|
||||
use bevy_ecs::prelude::ReflectComponent;
|
||||
use bevy_ecs::{
|
||||
change_detection::DetectChangesMut,
|
||||
component::Component,
|
||||
@ -331,7 +333,7 @@ pub enum ButtonSettingsError {
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Component, Debug)]
|
||||
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug))]
|
||||
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, Component))]
|
||||
#[require(GamepadSettings)]
|
||||
pub struct Gamepad {
|
||||
/// The USB vendor ID as assigned by the USB-IF, if available.
|
||||
@ -688,7 +690,11 @@ pub enum GamepadInput {
|
||||
/// should register. Events that don't meet the change thresholds defined in [`GamepadSettings`]
|
||||
/// will not register. To modify these settings, mutate the corresponding component.
|
||||
#[derive(Component, Clone, Default, Debug)]
|
||||
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, Default))]
|
||||
#[cfg_attr(
|
||||
feature = "bevy_reflect",
|
||||
derive(Reflect),
|
||||
reflect(Debug, Default, Component)
|
||||
)]
|
||||
pub struct GamepadSettings {
|
||||
/// The default button settings.
|
||||
pub default_button_settings: ButtonSettings,
|
||||
|
@ -166,6 +166,7 @@ pub type MainEntityHashSet = hashbrown::HashSet<MainEntity, EntityHash>;
|
||||
|
||||
/// Marker component that indicates that its entity needs to be despawned at the end of the frame.
|
||||
#[derive(Component, Copy, Clone, Debug, Default, Reflect)]
|
||||
#[reflect(Component)]
|
||||
pub struct TemporaryRenderEntity;
|
||||
|
||||
/// A record enum to what entities with [`SyncToRenderWorld`] have been added or removed.
|
||||
|
@ -2663,6 +2663,7 @@ impl<'w, 's> DefaultUiCamera<'w, 's> {
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Component, Clone, Copy, Default, Debug, Reflect, Eq, PartialEq)]
|
||||
#[reflect(Component)]
|
||||
pub enum UiAntiAlias {
|
||||
/// UI will render with anti-aliasing
|
||||
#[default]
|
||||
@ -2688,6 +2689,7 @@ pub enum UiAntiAlias {
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Component, Clone, Copy, Debug, Reflect, Eq, PartialEq)]
|
||||
#[reflect(Component)]
|
||||
pub struct BoxShadowSamples(pub u32);
|
||||
|
||||
impl Default for BoxShadowSamples {
|
||||
|
Loading…
Reference in New Issue
Block a user