diff --git a/crates/bevy_ui/src/entity.rs b/crates/bevy_ui/src/entity.rs index 3469ccb75f2aa..abb73fae70ec2 100644 --- a/crates/bevy_ui/src/entity.rs +++ b/crates/bevy_ui/src/entity.rs @@ -10,14 +10,16 @@ use bevy_ecs::{ query::QueryItem, }; use bevy_render::{ - camera::Camera, extract_component::ExtractComponent, prelude::ComputedVisibility, + camera::Camera, + extract_component::ExtractComponent, + prelude::{Color, ComputedVisibility}, view::Visibility, }; use bevy_text::{Text, TextAlignment, TextSection, TextStyle}; use bevy_transform::prelude::{GlobalTransform, Transform}; /// The basic UI node -#[derive(Bundle, Clone, Debug, Default)] +#[derive(Bundle, Clone, Debug)] pub struct NodeBundle { /// Describes the size of the node pub node: Node, @@ -45,6 +47,23 @@ pub struct NodeBundle { pub computed_visibility: ComputedVisibility, } +impl Default for NodeBundle { + fn default() -> Self { + NodeBundle { + // Transparent background + background_color: Color::NONE.into(), + node: Default::default(), + style: Default::default(), + image: Default::default(), + focus_policy: Default::default(), + transform: Default::default(), + global_transform: Default::default(), + visibility: Default::default(), + computed_visibility: Default::default(), + } + } +} + /// A UI node that is an image #[derive(Bundle, Clone, Debug, Default)] pub struct ImageBundle { diff --git a/examples/games/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs index 013d71fd6b6f7..27e3f1b359f0f 100644 --- a/examples/games/alien_cake_addict.rs +++ b/examples/games/alien_cake_addict.rs @@ -383,7 +383,6 @@ fn display_score(mut commands: Commands, asset_server: Res, game: R align_items: AlignItems::Center, ..default() }, - background_color: Color::NONE.into(), ..default() }) .with_children(|parent| { diff --git a/examples/ui/ui.rs b/examples/ui/ui.rs index fb627071bb1fe..3a18a3e3dbfed 100644 --- a/examples/ui/ui.rs +++ b/examples/ui/ui.rs @@ -28,7 +28,6 @@ fn setup(mut commands: Commands, asset_server: Res) { justify_content: JustifyContent::SpaceBetween, ..default() }, - background_color: Color::NONE.into(), ..default() }) .with_children(|parent| { @@ -130,7 +129,6 @@ fn setup(mut commands: Commands, asset_server: Res) { max_size: Size::UNDEFINED, ..default() }, - background_color: Color::NONE.into(), ..default() }, ScrollingList::default(), @@ -200,7 +198,6 @@ fn setup(mut commands: Commands, asset_server: Res) { justify_content: JustifyContent::Center, ..default() }, - background_color: Color::NONE.into(), ..default() }) .with_children(|parent| { @@ -283,7 +280,6 @@ fn setup(mut commands: Commands, asset_server: Res) { align_items: AlignItems::FlexEnd, ..default() }, - background_color: Color::NONE.into(), ..default() }) .with_children(|parent| { diff --git a/examples/window/scale_factor_override.rs b/examples/window/scale_factor_override.rs index 2dd38093e4ff2..648a67b5dc6df 100644 --- a/examples/window/scale_factor_override.rs +++ b/examples/window/scale_factor_override.rs @@ -28,7 +28,6 @@ fn setup(mut commands: Commands, asset_server: Res) { justify_content: JustifyContent::SpaceBetween, ..default() }, - background_color: Color::NONE.into(), ..default() }) .with_children(|parent| {