Skip to content

Commit

Permalink
don't render completely transparent UI nodes (bevyengine#5537)
Browse files Browse the repository at this point in the history
# Objective

- I often have UI nodes that are completely transparent and just for organisation
- Don't render them
- I doesn't bring a lot of improvements, but it doesn't add a lot of complexity either
  • Loading branch information
mockersf authored and inodentry committed Aug 19, 2022
1 parent 2b09a06 commit f5daa43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/bevy_render/src/color/mod.rs
Expand Up @@ -294,6 +294,7 @@ impl Color {
}

/// Get alpha.
#[inline(always)]
pub fn a(&self) -> f32 {
match self {
Color::Rgba { alpha, .. }
Expand Down
4 changes: 4 additions & 0 deletions crates/bevy_ui/src/render/mod.rs
Expand Up @@ -197,6 +197,10 @@ pub fn extract_uinodes(
if !images.contains(&image) {
continue;
}
// Skip completely transparent nodes
if color.0.a() == 0.0 {
continue;
}
extracted_uinodes.uinodes.push(ExtractedUiNode {
transform: transform.compute_matrix(),
color: color.0,
Expand Down

0 comments on commit f5daa43

Please sign in to comment.