UI Materials: ignore entities with a BackgroundColor component (#10434)

# 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
This commit is contained in:
François 2023-11-07 21:04:10 +01:00 committed by Carter Anderson
parent 07d6a12f46
commit e8ba68d702
2 changed files with 15 additions and 9 deletions

View File

@ -344,6 +344,9 @@ impl Default for ButtonBundle {
} }
/// A UI node that is rendered using a [`UiMaterial`] /// 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)] #[derive(Bundle, Clone, Debug)]
pub struct MaterialNodeBundle<M: UiMaterial> { pub struct MaterialNodeBundle<M: UiMaterial> {
/// Describes the logical size of the node /// Describes the logical size of the node

View File

@ -354,7 +354,8 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
materials: Extract<Res<Assets<M>>>, materials: Extract<Res<Assets<M>>>,
ui_stack: Extract<Res<UiStack>>, ui_stack: Extract<Res<UiStack>>,
uinode_query: Extract< uinode_query: Extract<
Query<( Query<
(
Entity, Entity,
&Node, &Node,
&Style, &Style,
@ -362,7 +363,9 @@ pub fn extract_ui_material_nodes<M: UiMaterial>(
&Handle<M>, &Handle<M>,
&ViewVisibility, &ViewVisibility,
Option<&CalculatedClip>, Option<&CalculatedClip>,
)>, ),
Without<BackgroundColor>,
>,
>, >,
windows: Extract<Query<&Window, With<PrimaryWindow>>>, windows: Extract<Query<&Window, With<PrimaryWindow>>>,
ui_scale: Extract<Res<UiScale>>, ui_scale: Extract<Res<UiScale>>,