pub trait HierarchyQueryExt<'w, 's, Q, F>where
    Q: WorldQuery,
    F: ReadOnlyWorldQuery,
{ fn iter_descendants(&'w self, entity: Entity) -> DescendantIter<'w, 's, Q, F>
    where
        <Q as WorldQuery>::ReadOnly: WorldQuery<Item<'w> = &'w Children>
; fn iter_ancestors(&'w self, entity: Entity) -> AncestorIter<'w, 's, Q, F>
    where
        <Q as WorldQuery>::ReadOnly: WorldQuery<Item<'w> = &'w Parent>
; }
Expand description

An extension trait for Query that adds hierarchy related methods.

Required Methods

Returns an Iterator of Entitys over all of entitys descendants.

Can only be called on a Query of Children (i.e. Query<&Children>).

Traverses the hierarchy breadth-first.

Examples
fn system(query: Query<Entity, With<Marker>>, children_query: Query<&Children>) {
    let entity = query.single();
    for descendant in children_query.iter_descendants(entity) {
        // Do something!
    }
}

Returns an Iterator of Entitys over all of entitys ancestors.

Can only be called on a Query of Parent (i.e. Query<&Parent>).

Examples
fn system(query: Query<Entity, With<Marker>>, parent_query: Query<&Parent>) {
    let entity = query.single();
    for ancestor in parent_query.iter_ancestors(entity) {
        // Do something!
    }
}

Implementors