Skip to content

Commit

Permalink
UI Materials: ignore entities with a BackgroundColor component (#10434
Browse files Browse the repository at this point in the history
)

# Objective

- Entities with both a `BackgroundColor` and a
`Handle<CustomUiMaterial>` are extracted by both pipelines and results
in entities being overwritten in the render world
- Fixes #10431 

## Solution

- Ignore entities with `BackgroundColor` when extracting ui material
entities, and document that limit
  • Loading branch information
mockersf authored Nov 7, 2023
1 parent aaef557 commit 72a6106
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions crates/bevy_ui/src/node_bundles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ impl Default for ButtonBundle {
}

/// A UI node that is rendered using a [`UiMaterial`]
///
/// Adding a `BackgroundColor` component to an entity with this bundle will ignore the custom
/// material and use the background color instead.
#[derive(Bundle, Clone, Debug)]
pub struct MaterialNodeBundle<M: UiMaterial> {
/// Describes the logical size of the node
Expand Down
21 changes: 12 additions & 9 deletions crates/bevy_ui/src/render/ui_material_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,18 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
materials: Extract<Res<Assets<M>>>,
ui_stack: Extract<Res<UiStack>>,
uinode_query: Extract<
Query<(
Entity,
&Node,
&Style,
&GlobalTransform,
&Handle<M>,
&ViewVisibility,
Option<&CalculatedClip>,
)>,
Query<
(
Entity,
&Node,
&Style,
&GlobalTransform,
&Handle<M>,
&ViewVisibility,
Option<&CalculatedClip>,
),
Without<BackgroundColor>,
>,
>,
windows: Extract<Query<&Window, With<PrimaryWindow>>>,
ui_scale: Extract<Res<UiScale>>,
Expand Down

0 comments on commit 72a6106

Please sign in to comment.