Crates.io | bevy_despawn_with |
lib.rs | bevy_despawn_with |
version | 0.15.0 |
source | src |
created_at | 2022-02-26 10:43:40.450325 |
updated_at | 2023-03-08 16:34:59.931597 |
description | Commands extension trait for despawning multiple entities |
homepage | |
repository | https://github.com/ickshonpe/bevy_despawn_with |
max_upload_size | |
id | 539883 |
size | 71,351 |
This crate implements an extension trait on Commands
, DespawnAllCommandsExt
which has two methods despawn_all
and despawn_all_recursive
for despawning multiple entities:
fn despawn_system(
mut commands: Commands,
) {
commands.despawn_all::<(With<People>, With<Shoes>, Without<Laces>)>();
}
Add the dependency to your project's Cargo.toml [dependencies]
section:
bevy_despawn_with = "0.15.0"
Then despawn some things:
use bevy_despawn_with::DespawnAllCommandsExt;
fn despawn_system(mut commands: Commands) {
// Despawn all entities with a MenuUiMarker component
commands.despawn_all::<With<MenuUiMarker>>();
// Despawn all entities without a SomeOtherMarker component,
// and despawn those entities descendants.
commands.despawn_all_recursive::<Without<SomeOtherMarker>>();
// Despawn all entities with a MenuUiMarker component, or with a changed GlobalTransform.
commands.despawn_all::<Or<(With<MenUiMarker>, Changed<GlobalTransform>)>>();
}
cargo run --example despawn_with
cargo run --example despawn_without
Supports Bevy 0.10