From 53d2bc948223aaa220ecd918b16170a2996c72e1 Mon Sep 17 00:00:00 2001 From: Blazepaws <157802762+blazepaws@users.noreply.github.com> Date: Sun, 15 Sep 2024 16:23:54 +0200 Subject: [PATCH] Reflect derived traits on all components and resources: bevy_ecs (#15215) Solves https://github.com/bevyengine/bevy/issues/15187 for bevy_ecs --- crates/bevy_ecs/src/event/collections.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/event/collections.rs b/crates/bevy_ecs/src/event/collections.rs index 3f5417d500..f14e348edc 100644 --- a/crates/bevy_ecs/src/event/collections.rs +++ b/crates/bevy_ecs/src/event/collections.rs @@ -1,10 +1,12 @@ use crate as bevy_ecs; +#[cfg(feature = "bevy_reflect")] +use bevy_ecs::reflect::ReflectResource; use bevy_ecs::{ event::{Event, EventCursor, EventId, EventInstance}, system::Resource, }; #[cfg(feature = "bevy_reflect")] -use bevy_reflect::Reflect; +use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_utils::detailed_trace; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; @@ -85,7 +87,7 @@ use std::ops::{Deref, DerefMut}; /// [`EventWriter`]: super::EventWriter /// [`event_update_system`]: super::event_update_system #[derive(Debug, Resource)] -#[cfg_attr(feature = "bevy_reflect", derive(Reflect))] +#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Resource, Default))] pub struct Events { /// Holds the oldest still active events. /// Note that `a.start_event_count + a.len()` should always be equal to `events_b.start_event_count`.