Avoid panicking with non-UI nodes (#12213)

# Objective

- Fixes https://github.com/bevyengine/bevy/issues/10826
- Fixes https://github.com/bevyengine/bevy/issues/9615

## Solution

- Early-out when components are missing.
This commit is contained in:
Sludge 2024-02-29 22:36:45 +01:00 committed by François
parent 8234978ab0
commit b8c58dedd9
2 changed files with 6 additions and 2 deletions

View File

@ -411,7 +411,9 @@ pub fn ui_layout_system(
mut absolute_location: Vec2, mut absolute_location: Vec2,
) { ) {
if let Ok((mut node, mut transform)) = node_transform_query.get_mut(entity) { 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 = let layout_size =
inverse_target_scale_factor * Vec2::new(layout.size.width, layout.size.height); inverse_target_scale_factor * Vec2::new(layout.size.width, layout.size.height);
let layout_location = let layout_location =

View File

@ -155,7 +155,9 @@ fn update_children_target_camera(
for &child in children { for &child in children {
// Skip if the child has already been updated or update is not needed // 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; continue;
} }