[]Struct bevy::ecs::EntityBuilder

pub struct EntityBuilder { /* fields omitted */ }

Helper for incrementally constructing a bundle of components with dynamic component types

Prefer reusing the same builder over creating new ones repeatedly.

let mut world = World::new();
let mut builder = EntityBuilder::new();
builder.add(123).add("abc");
let e = world.spawn(builder.build()); // builder can now be reused
assert_eq!(*world.get::<i32>(e).unwrap(), 123);
assert_eq!(*world.get::<&str>(e).unwrap(), "abc");

Implementations

impl EntityBuilder

pub fn new() -> EntityBuilder

Create a builder representing an entity with no components

pub fn add<T>(&mut self, component: T) -> &mut EntityBuilder where
    T: Component

Add component to the entity

pub fn build(&mut self) -> BuiltEntity<'_>

Construct a Bundle suitable for spawning

pub fn clear(&mut self)

Drop previously added components

The builder is cleared implicitly when an entity is built, so this doesn't usually need to be called.

Trait Implementations

impl Default for EntityBuilder

impl Drop for EntityBuilder

impl Send for EntityBuilder

impl Sync for EntityBuilder

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Component for T where
    T: 'static + Send + Sync

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> From<T> for T[src]

impl<T> FromResources for T where
    T: Default

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Resource for T where
    T: 'static + Send + Sync

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,