Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a with_child method to BuildChildren #6712

Closed
alice-i-cecile opened this issue Nov 21, 2022 · 0 comments
Closed

Add a with_child method to BuildChildren #6712

alice-i-cecile opened this issue Nov 21, 2022 · 0 comments
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Nov 21, 2022

When reviewing #6535, I noticed that calling .build_children with a single child is quite onerous.

We should have the follow method on the BuildChildren trait:

fn with_child(&mut self, bundle: impl Bundle) -> &mut Self

This allows users to quickly add single children without worrying about a closure, or even chain the method repeatedly if they just want to add a fixed number of children.

@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Hierarchy labels Nov 21, 2022
@alice-i-cecile alice-i-cecile moved this to Todo in UI Nov 21, 2022
@alice-i-cecile alice-i-cecile removed the D-Trivial Nice and easy! A great choice to get started with Bevy label Nov 21, 2022
bors bot pushed a commit that referenced this issue Nov 28, 2022
# Objective

- Adding a single child is very cumbersome, and requires the use of a complex closure.
- Fixes #6712.

## Solution

Add a `with_child(b: impl Bundle)` API.

## Changelog

Added `EntityCommands::with_child(b: impl Bundle)`  and an equivelent method on `EntityMut`  (for direct world access).

## Migration Guide

When spawning a single child with no children of its own, consider using `commands.entity(parent).with_child(child_bundle)` to make your code clearer.
bors bot pushed a commit that referenced this issue Nov 28, 2022
# Objective

- Adding a single child is very cumbersome, and requires the use of a complex closure.
- Fixes #6712.

## Solution

Add a `with_child(b: impl Bundle)` API.

## Changelog

Added `EntityCommands::with_child(b: impl Bundle)`  and an equivelent method on `EntityMut`  (for direct world access).

## Migration Guide

When spawning a single child with no children of its own, consider using `commands.entity(parent).with_child(child_bundle)` to make your code clearer.
bors bot pushed a commit that referenced this issue Nov 28, 2022
# Objective

- Adding a single child is very cumbersome, and requires the use of a complex closure.
- Fixes #6712.

## Solution

Add a `with_child(b: impl Bundle)` API.

## Changelog

Added `EntityCommands::with_child(b: impl Bundle)`  and an equivelent method on `EntityMut`  (for direct world access).

## Migration Guide

When spawning a single child with no children of its own, consider using `commands.entity(parent).with_child(child_bundle)` to make your code clearer.
@github-project-automation github-project-automation bot moved this from Todo to Done in UI Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant