diff --git a/crates/bevy_ecs/src/observer/mod.rs b/crates/bevy_ecs/src/observer/mod.rs index 600384d478..3ef2d6b28d 100644 --- a/crates/bevy_ecs/src/observer/mod.rs +++ b/crates/bevy_ecs/src/observer/mod.rs @@ -12,7 +12,7 @@ use crate::{archetype::ArchetypeFlags, system::IntoObserverSystem, world::*}; use crate::{component::ComponentId, prelude::*, world::DeferredWorld}; use bevy_ptr::Ptr; use bevy_utils::{EntityHashMap, HashMap}; -use std::marker::PhantomData; +use std::{fmt::Debug, marker::PhantomData}; /// Type containing triggered [`Event`] information for a given run of an [`Observer`]. This contains the /// [`Event`] data itself. If it was triggered for a specific [`Entity`], it includes that as well. It also @@ -84,6 +84,17 @@ impl<'w, E, B: Bundle> Trigger<'w, E, B> { } } +impl<'w, E: Debug, B: Bundle> Debug for Trigger<'w, E, B> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Trigger") + .field("event", &self.event) + .field("propagate", &self.propagate) + .field("trigger", &self.trigger) + .field("_marker", &self._marker) + .finish() + } +} + /// A description of what an [`Observer`] observes. #[derive(Default, Clone)] pub struct ObserverDescriptor { diff --git a/crates/bevy_ecs/src/world/component_constants.rs b/crates/bevy_ecs/src/world/component_constants.rs index 92c1572b09..ead0e5ac9f 100644 --- a/crates/bevy_ecs/src/world/component_constants.rs +++ b/crates/bevy_ecs/src/world/component_constants.rs @@ -16,24 +16,28 @@ pub const ON_REMOVE: ComponentId = ComponentId::new(3); /// Trigger emitted when a component is added to an entity. See [`crate::component::ComponentHooks::on_add`] /// for more information. -#[derive(Event)] +#[derive(Event, Debug)] #[cfg_attr(feature = "bevy_reflect", derive(Reflect))] +#[cfg_attr(feature = "bevy_reflect", reflect(Debug))] pub struct OnAdd; /// Trigger emitted when a component is inserted onto an entity. See [`crate::component::ComponentHooks::on_insert`] /// for more information. -#[derive(Event)] +#[derive(Event, Debug)] #[cfg_attr(feature = "bevy_reflect", derive(Reflect))] +#[cfg_attr(feature = "bevy_reflect", reflect(Debug))] pub struct OnInsert; /// Trigger emitted when a component is replaced on an entity. See [`crate::component::ComponentHooks::on_replace`] /// for more information. -#[derive(Event)] +#[derive(Event, Debug)] #[cfg_attr(feature = "bevy_reflect", derive(Reflect))] +#[cfg_attr(feature = "bevy_reflect", reflect(Debug))] pub struct OnReplace; /// Trigger emitted when a component is removed from an entity. See [`crate::component::ComponentHooks::on_remove`] /// for more information. -#[derive(Event)] +#[derive(Event, Debug)] #[cfg_attr(feature = "bevy_reflect", derive(Reflect))] +#[cfg_attr(feature = "bevy_reflect", reflect(Debug))] pub struct OnRemove;