#[derive(Bundle)]
{
// Attributes available to this derive:
#[bundle]
}
Expand description
Derive the Bundle
trait
You can apply this derive macro to structs that are
composed of Component
s or
other Bundle
s.
ยงAttributes
Sometimes parts of the Bundle should not be inserted.
Those can be marked with #[bundle(ignore)]
, and they will be skipped.
In that case, the field needs to implement Default
unless you also ignore
the BundleFromComponents
implementation.
#[derive(Bundle)]
struct HitpointMarker {
hitpoints: Hitpoint,
#[bundle(ignore)]
creator: Option<String>
}
Some fields may be bundles that do not implement
BundleFromComponents
. This happens for bundles that cannot be extracted.
For example with SpawnRelatedBundle
, see below for an
example usage.
In those cases you can either ignore it as above,
or you can opt out the whole Struct by marking it as ignored with
#[bundle(ignore_from_components)]
.
use bevy_ecs::spawn::SpawnRelatedBundle;
#[derive(Bundle)]
#[bundle(ignore_from_components)]
struct HitpointMarker {
hitpoints: Hitpoint,
related_spawner: SpawnRelatedBundle<ChildOf, Spawn<Marker>>,
}
Implement the Bundle
trait.