pub trait BuildChildren {
    // Required methods
    fn with_children(
        &mut self,
        f: impl FnOnce(&mut ChildBuilder<'_, '_, '_>)
    ) -> &mut Self;
    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;
    fn clear_children(&mut self) -> &mut Self;
    fn replace_children(&mut self, children: &[Entity]) -> &mut Self;
    fn set_parent(&mut self, parent: Entity) -> &mut Self;
    fn remove_parent(&mut self) -> &mut Self;
}
Expand description

Trait defining how to build children

Required Methods§

source

fn with_children( &mut self, f: impl FnOnce(&mut ChildBuilder<'_, '_, '_>) ) -> &mut Self

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

source

fn push_children(&mut self, children: &[Entity]) -> &mut Self

Pushes children to the back of the builder’s children. For any entities that are already a child of this one, this method does nothing.

If the children were previously children of another parent, that parent’s Children component will have those children removed from its list. Removing all children from a parent causes its Children component to be removed from the entity.

source

fn insert_children(&mut self, index: usize, children: &[Entity]) -> &mut Self

Inserts children at the given index

If the children were previously children of another parent, that parent’s Children component will have those children removed from its list. Removing all children from a parent causes its Children component to be removed from the entity.

source

fn remove_children(&mut self, children: &[Entity]) -> &mut Self

Removes the given children

Removing all children from a parent causes its Children component to be removed from the entity.

source

fn add_child(&mut self, child: Entity) -> &mut Self

Adds a single child

If the children were previously children of another parent, that parent’s Children component will have those children removed from its list. Removing all children from a parent causes its Children component to be removed from the entity.

source

fn clear_children(&mut self) -> &mut Self

Removes all children from this entity. The Children component will be removed if it exists, otherwise this does nothing.

source

fn replace_children(&mut self, children: &[Entity]) -> &mut Self

Removes all current children from this entity, replacing them with the specified list of entities.

source

fn set_parent(&mut self, parent: Entity) -> &mut Self

Sets the parent of this entity.

source

fn remove_parent(&mut self) -> &mut Self

Removes the parent of this entity.

Implementations on Foreign Types§

source§

impl<'w, 's, 'a> BuildChildren for EntityCommands<'w, 's, 'a>

source§

fn with_children( &mut self, spawn_children: impl FnOnce(&mut ChildBuilder<'_, '_, '_>) ) -> &mut Self

source§

fn push_children(&mut self, children: &[Entity]) -> &mut Self

source§

fn insert_children(&mut self, index: usize, children: &[Entity]) -> &mut Self

source§

fn remove_children(&mut self, children: &[Entity]) -> &mut Self

source§

fn add_child(&mut self, child: Entity) -> &mut Self

source§

fn clear_children(&mut self) -> &mut Self

source§

fn replace_children(&mut self, children: &[Entity]) -> &mut Self

source§

fn set_parent(&mut self, parent: Entity) -> &mut Self

source§

fn remove_parent(&mut self) -> &mut Self

Implementors§