mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Replace uses of entity.insert
with tuple bundles in game_menu
example (#9619)
# Objective Change two places where `entity.insert` is used to add components individually to spawn a tuple bundle instead.
This commit is contained in:
parent
ce2ade2636
commit
2b2abcef97
1 changed files with 23 additions and 18 deletions
|
@ -654,16 +654,19 @@ mod menu {
|
||||||
DisplayQuality::Medium,
|
DisplayQuality::Medium,
|
||||||
DisplayQuality::High,
|
DisplayQuality::High,
|
||||||
] {
|
] {
|
||||||
let mut entity = parent.spawn(ButtonBundle {
|
let mut entity = parent.spawn((
|
||||||
style: Style {
|
ButtonBundle {
|
||||||
width: Val::Px(150.0),
|
style: Style {
|
||||||
height: Val::Px(65.0),
|
width: Val::Px(150.0),
|
||||||
..button_style.clone()
|
height: Val::Px(65.0),
|
||||||
|
..button_style.clone()
|
||||||
|
},
|
||||||
|
background_color: NORMAL_BUTTON.into(),
|
||||||
|
..default()
|
||||||
},
|
},
|
||||||
background_color: NORMAL_BUTTON.into(),
|
quality_setting,
|
||||||
..default()
|
));
|
||||||
});
|
entity.with_children(|parent| {
|
||||||
entity.insert(quality_setting).with_children(|parent| {
|
|
||||||
parent.spawn(TextBundle::from_section(
|
parent.spawn(TextBundle::from_section(
|
||||||
format!("{quality_setting:?}"),
|
format!("{quality_setting:?}"),
|
||||||
button_text_style.clone(),
|
button_text_style.clone(),
|
||||||
|
@ -746,16 +749,18 @@ mod menu {
|
||||||
button_text_style.clone(),
|
button_text_style.clone(),
|
||||||
));
|
));
|
||||||
for volume_setting in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {
|
for volume_setting in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {
|
||||||
let mut entity = parent.spawn(ButtonBundle {
|
let mut entity = parent.spawn((
|
||||||
style: Style {
|
ButtonBundle {
|
||||||
width: Val::Px(30.0),
|
style: Style {
|
||||||
height: Val::Px(65.0),
|
width: Val::Px(30.0),
|
||||||
..button_style.clone()
|
height: Val::Px(65.0),
|
||||||
|
..button_style.clone()
|
||||||
|
},
|
||||||
|
background_color: NORMAL_BUTTON.into(),
|
||||||
|
..default()
|
||||||
},
|
},
|
||||||
background_color: NORMAL_BUTTON.into(),
|
Volume(volume_setting),
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
entity.insert(Volume(volume_setting));
|
|
||||||
if *volume == Volume(volume_setting) {
|
if *volume == Volume(volume_setting) {
|
||||||
entity.insert(SelectedOption);
|
entity.insert(SelectedOption);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue