mirror of
https://github.com/bevyengine/bevy
synced 2024-12-24 20:13:07 +00:00
81db6ec70a
# Objective Run this without this PR: `cargo build -p bevy_hierarchy --no-default-features` You'll get: ``` error[E0432]: unresolved import `bevy_reflect` --> crates/bevy_hierarchy/src/events.rs:2:5 | 2 | use bevy_reflect::Reflect; | ^^^^^^^^^^^^ use of undeclared crate or module `bevy_reflect` For more information about this error, try `rustc --explain E0432`. error: could not compile `bevy_hierarchy` (lib) due to 1 previous error warning: build failed, waiting for other jobs to finish... ``` Because of this line: ```rs use bevy_reflect::Reflect; #[derive(Event, Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "reflect", derive(Reflect), reflect(Debug, PartialEq))] pub enum HierarchyEvent { .. } ``` ## Solution use FQN: `derive(bevy_reflect::Reflect)` ## Testing `cargo build -p bevy_hierarchy --no-default-features`
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
use bevy_ecs::{event::Event, prelude::Entity};
|
|
#[cfg(feature = "reflect")]
|
|
use bevy_reflect::Reflect;
|
|
|
|
/// An [`Event`] that is fired whenever there is a change in the world's hierarchy.
|
|
///
|
|
/// [`Event`]: bevy_ecs::event::Event
|
|
#[derive(Event, Debug, Clone, PartialEq, Eq)]
|
|
#[cfg_attr(feature = "reflect", derive(Reflect), reflect(Debug, PartialEq))]
|
|
pub enum HierarchyEvent {
|
|
/// Fired whenever an [`Entity`] is added as a child to a parent.
|
|
ChildAdded {
|
|
/// The child that was added
|
|
child: Entity,
|
|
/// The parent the child was added to
|
|
parent: Entity,
|
|
},
|
|
/// Fired whenever a child [`Entity`] is removed from its parent.
|
|
ChildRemoved {
|
|
/// The child that was removed
|
|
child: Entity,
|
|
/// The parent the child was removed from
|
|
parent: Entity,
|
|
},
|
|
/// Fired whenever a child [`Entity`] is moved to a new parent.
|
|
ChildMoved {
|
|
/// The child that was moved
|
|
child: Entity,
|
|
/// The parent the child was removed from
|
|
previous_parent: Entity,
|
|
/// The parent the child was added to
|
|
new_parent: Entity,
|
|
},
|
|
}
|