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 james7132 committed Oct 28, 2022
1 parent 3ac8850 commit 88ca052
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
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,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
Original file line number Diff line number Diff line change
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 88ca052

Please sign in to comment.