diff --git a/crates/bevy_ui/src/stack.rs b/crates/bevy_ui/src/stack.rs index 582d88ca0af573..ec389daa591446 100644 --- a/crates/bevy_ui/src/stack.rs +++ b/crates/bevy_ui/src/stack.rs @@ -58,11 +58,9 @@ pub fn ui_stack_system( fill_stack_recursively(&mut ui_stack.uinodes, &mut global_context); for (i, entity) in ui_stack.uinodes.iter().enumerate() { - update_query - .get_mut(*entity) - .unwrap() - .bypass_change_detection() - .stack_index = i as u32; + if let Ok(mut node) = update_query.get_mut(*entity) { + node.bypass_change_detection().stack_index = i as u32; + } } }