Skip to content

Commit 2b2abce

Browse files
authored
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.
1 parent ce2ade2 commit 2b2abce

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

examples/games/game_menu.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -654,16 +654,19 @@ mod menu {
654654
DisplayQuality::Medium,
655655
DisplayQuality::High,
656656
] {
657-
let mut entity = parent.spawn(ButtonBundle {
658-
style: Style {
659-
width: Val::Px(150.0),
660-
height: Val::Px(65.0),
661-
..button_style.clone()
657+
let mut entity = parent.spawn((
658+
ButtonBundle {
659+
style: Style {
660+
width: Val::Px(150.0),
661+
height: Val::Px(65.0),
662+
..button_style.clone()
663+
},
664+
background_color: NORMAL_BUTTON.into(),
665+
..default()
662666
},
663-
background_color: NORMAL_BUTTON.into(),
664-
..default()
665-
});
666-
entity.insert(quality_setting).with_children(|parent| {
667+
quality_setting,
668+
));
669+
entity.with_children(|parent| {
667670
parent.spawn(TextBundle::from_section(
668671
format!("{quality_setting:?}"),
669672
button_text_style.clone(),
@@ -746,16 +749,18 @@ mod menu {
746749
button_text_style.clone(),
747750
));
748751
for volume_setting in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {
749-
let mut entity = parent.spawn(ButtonBundle {
750-
style: Style {
751-
width: Val::Px(30.0),
752-
height: Val::Px(65.0),
753-
..button_style.clone()
752+
let mut entity = parent.spawn((
753+
ButtonBundle {
754+
style: Style {
755+
width: Val::Px(30.0),
756+
height: Val::Px(65.0),
757+
..button_style.clone()
758+
},
759+
background_color: NORMAL_BUTTON.into(),
760+
..default()
754761
},
755-
background_color: NORMAL_BUTTON.into(),
756-
..default()
757-
});
758-
entity.insert(Volume(volume_setting));
762+
Volume(volume_setting),
763+
));
759764
if *volume == Volume(volume_setting) {
760765
entity.insert(SelectedOption);
761766
}

0 commit comments

Comments
 (0)