logo
pub trait BuildChildren {
    fn with_children(
        &mut self,
        f: impl FnOnce(&mut ChildBuilder<'_, '_, '_>)
    ) -> &mut Self; fn add_children<T>(
        &mut self,
        f: impl FnOnce(&mut ChildBuilder<'_, '_, '_>) -> T
    ) -> T; fn push_children(&mut self, children: &[Entity]) -> &mut Self; fn insert_children(&mut self, index: usize, children: &[Entity]) -> &mut Self; fn remove_children(&mut self, children: &[Entity]) -> &mut Self; fn add_child(&mut self, child: Entity) -> &mut Self; }
Expand description

Trait defining how to build children

Required Methods

Creates a ChildBuilder with the given children built in the given closure

Compared to add_children, this method returns self to allow chaining.

Creates a ChildBuilder with the given children built in the given closure

Compared to with_children, this method returns the the value returned from the closure, but doesn’t allow chaining.

Example
    let mut parent_commands = commands.spawn();
    let child_id = parent_commands.add_children(|parent| {
        parent.spawn().id()
    });

    parent_commands.insert(SomethingElse);
    commands.entity(child_id).with_children(|parent| {
        parent.spawn().insert(MoreStuff);
    });

Pushes children to the back of the builder’s children

Inserts children at the given index

Removes the given children

Adds a single child

Implementors