mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
Add a doc note about despawn footgun (#10889)
# Objective The `Despawn` command breaks the hierarchy whenever you use it if the despawned entity has a parent or any children. This is a serious footgun because the `Despawn` command has the shortest name, the behavior is unexpected and not likely to be what you want, and the crash that it causes can be very difficult to track down. ## Solution Until this can be fixed by relations, add a note mentioning the footgun in the documentation.
This commit is contained in:
parent
6a15ed564d
commit
9c8576996f
2 changed files with 16 additions and 0 deletions
|
@ -857,6 +857,11 @@ impl<'w, 's, 'a> EntityCommands<'w, 's, 'a> {
|
|||
///
|
||||
/// See [`World::despawn`] for more details.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This won't clean up external references to the entity (such as parent-child relationships
|
||||
/// if you're using `bevy_hierarchy`), which may leave the world in an invalid state.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// The command will panic when applied if the associated entity does not exist.
|
||||
|
@ -1056,6 +1061,11 @@ where
|
|||
|
||||
/// A [`Command`] that despawns a specific entity.
|
||||
/// This will emit a warning if the entity does not exist.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This won't clean up external references to the entity (such as parent-child relationships
|
||||
/// if you're using `bevy_hierarchy`), which may leave the world in an invalid state.
|
||||
#[derive(Debug)]
|
||||
pub struct Despawn {
|
||||
/// The entity that will be despawned.
|
||||
|
|
|
@ -852,6 +852,12 @@ impl World {
|
|||
/// Despawns the given `entity`, if it exists. This will also remove all of the entity's
|
||||
/// [`Component`]s. Returns `true` if the `entity` is successfully despawned and `false` if
|
||||
/// the `entity` does not exist.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This won't clean up external references to the entity (such as parent-child relationships
|
||||
/// if you're using `bevy_hierarchy`), which may leave the world in an invalid state.
|
||||
///
|
||||
/// ```
|
||||
/// use bevy_ecs::{component::Component, world::World};
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue