Skip to content

Allow multiple children! in one bundle #19398

Open
@molikto

Description

@molikto

What problem does this solve or what need does it fill?

commands.spawn((
     children![],
     children![],
 ));

currently crash with has duplicate components: bevy_ecs::hierarchy::Children

What solution would you like?

Allow multiple bevy_ecs::hierarchy::Children and merge them.

maybe some component can have a "merge strategy" instead of panic.

or maybe it will be solved as part of bsn?

What alternative(s) have you considered?

Additional context

I want to have this:

pub fn children_opt<T: Bundle>(opt: Option<T>) -> impl Bundle {
    Children::spawn(
        SpawnIter(opt.into_iter())
    )
}
pub fn two_opt_children_bundle(
) -> impl Bundle {
    (
        children_opt(Some(Name::new("c1"))),
        children_opt(Some(Name::new("c2")))
    )
}

Also if we can do this then it gives an alternative solution to #18953, you can have the cfg outside one children! marco, and have another one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-ComplexQuite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions