From efb4fa5d615cd3a1866aefbf1ab57b0373486a6f Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Sat, 23 Dec 2023 05:07:30 +0000 Subject: [PATCH] Give UI nodes with `Display::None` an empty clipping rect (#10942) # Objective Outlines are drawn for UI nodes with `Display::None` set and their descendants. They should not be visible. ## Solution Make all Nodes with `Display::None` inherit an empty clipping rect, ensuring that the outlines are not visible. Fixes #10940 --- ## Changelog * In `update_clipping_system` if a node has `Display::None` set, clip the entire node and all its descendants by replacing the inherited clip with a default rect (which is empty) --- crates/bevy_ui/src/update.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ui/src/update.rs b/crates/bevy_ui/src/update.rs index dd524be517..225ed08325 100644 --- a/crates/bevy_ui/src/update.rs +++ b/crates/bevy_ui/src/update.rs @@ -1,6 +1,6 @@ //! This module contains systems that update the UI when something changes -use crate::{CalculatedClip, OverflowAxis, Style}; +use crate::{CalculatedClip, Display, OverflowAxis, Style}; use super::Node; use bevy_ecs::{ @@ -35,13 +35,18 @@ fn update_clipping( children_query: &Query<&Children>, node_query: &mut Query<(&Node, &GlobalTransform, &Style, Option<&mut CalculatedClip>)>, entity: Entity, - maybe_inherited_clip: Option, + mut maybe_inherited_clip: Option, ) { let Ok((node, global_transform, style, maybe_calculated_clip)) = node_query.get_mut(entity) else { return; }; + // If `display` is None, clip the entire node and all its descendants by replacing the inherited clip with a default rect (which is empty) + if style.display == Display::None { + maybe_inherited_clip = Some(Rect::default()); + } + // Update this node's CalculatedClip component if let Some(mut calculated_clip) = maybe_calculated_clip { if let Some(inherited_clip) = maybe_inherited_clip {