Skip to content

Commit

Permalink
Avoid panicking with non-UI nodes (#12213)
Browse files Browse the repository at this point in the history
# Objective

- Fixes #10826
- Fixes #9615

## Solution

- Early-out when components are missing.
  • Loading branch information
SludgePhD authored Feb 29, 2024
1 parent 599e5e4 commit 080f280
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion crates/bevy_ui/src/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ pub fn ui_layout_system(
mut absolute_location: Vec2,
) {
if let Ok((mut node, mut transform)) = node_transform_query.get_mut(entity) {
let layout = ui_surface.get_layout(entity).unwrap();
let Ok(layout) = ui_surface.get_layout(entity) else {
return;
};
let layout_size =
inverse_target_scale_factor * Vec2::new(layout.size.width, layout.size.height);
let layout_location =
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_ui/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ fn update_children_target_camera(

for &child in children {
// Skip if the child has already been updated or update is not needed
if updated_entities.contains(&child) || camera_to_set == node_query.get(child).unwrap() {
if updated_entities.contains(&child)
|| camera_to_set == node_query.get(child).ok().flatten()
{
continue;
}

Expand Down

0 comments on commit 080f280

Please sign in to comment.