Skip to content

Commit

Permalink
Fix border color in ui_texture_slice and ui_texture_atlas_slice e…
Browse files Browse the repository at this point in the history
…xamples. (bevyengine#14121)

# Objective

Fixes bevyengine#14120

`ui_texture_slice` and `ui_texture_atlas_slice` were working as
intended, so undo the changes.

## Solution

Partially revert bevyengine#14115 for
`ui_texture_slice` and `ui_texture_atlas_slice`.

## Testing

Ran those two examples, confirmed the border color is the thing that
changes when buttons are hovered.
  • Loading branch information
rparrett authored and MrGVSV committed Jul 5, 2024
1 parent b6f9c11 commit 401fa35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
15 changes: 5 additions & 10 deletions examples/ui/ui_texture_atlas_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,26 @@ fn main() {

fn button_system(
mut interaction_query: Query<
(
&Interaction,
&mut TextureAtlas,
&Children,
&mut BackgroundColor,
),
(&Interaction, &mut TextureAtlas, &Children, &mut UiImage),
(Changed<Interaction>, With<Button>),
>,
mut text_query: Query<&mut Text>,
) {
for (interaction, mut atlas, children, mut color) in &mut interaction_query {
for (interaction, mut atlas, children, mut image) in &mut interaction_query {
let mut text = text_query.get_mut(children[0]).unwrap();
match *interaction {
Interaction::Pressed => {
text.sections[0].value = "Press".to_string();
atlas.index = (atlas.index + 1) % 30;
*color = GOLD.into();
image.color = GOLD.into();
}
Interaction::Hovered => {
text.sections[0].value = "Hover".to_string();
*color = ORANGE.into();
image.color = ORANGE.into();
}
Interaction::None => {
text.sections[0].value = "Button".to_string();
*color = Color::BLACK.into();
image.color = Color::WHITE;
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/ui/ui_texture_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ fn main() {

fn button_system(
mut interaction_query: Query<
(&Interaction, &Children, &mut BackgroundColor),
(&Interaction, &Children, &mut UiImage),
(Changed<Interaction>, With<Button>),
>,
mut text_query: Query<&mut Text>,
) {
for (interaction, children, mut color) in &mut interaction_query {
for (interaction, children, mut image) in &mut interaction_query {
let mut text = text_query.get_mut(children[0]).unwrap();
match *interaction {
Interaction::Pressed => {
text.sections[0].value = "Press".to_string();
*color = GOLD.into();
image.color = GOLD.into();
}
Interaction::Hovered => {
text.sections[0].value = "Hover".to_string();
*color = ORANGE.into();
image.color = ORANGE.into();
}
Interaction::None => {
text.sections[0].value = "Button".to_string();
*color = Color::BLACK.into();
image.color = Color::WHITE;
}
}
}
Expand Down

0 comments on commit 401fa35

Please sign in to comment.