Trait Prefab

Source
pub trait Prefab: 'static {
    type Marker: Component + Default;

    // Required method
    fn spawn(self, target: Entity, world: &mut World);

    // Provided method
    fn extract(builder: SnapshotBuilder<'_>) -> SnapshotBuilder<'_> { ... }
}
Expand description

Abstract spawning for entity types

Required Associated Types§

Source

type Marker: Component + Default

Marker component uniquely identifying the prefab entity

This is automatically inserted for you when spawning the prefab.

Required Methods§

Source

fn spawn(self, target: Entity, world: &mut World)

Create a single instance of the prefab

Provided Methods§

Source

fn extract(builder: SnapshotBuilder<'_>) -> SnapshotBuilder<'_>

Extract the prefab entities from the World

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§