Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Make the default background color of NodeBundle transparent #6211

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions crates/bevy_ui/src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion examples/games/alien_cake_addict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ fn display_score(mut commands: Commands, asset_server: Res<AssetServer>, game: R
align_items: AlignItems::Center,
..default()
},
background_color: Color::NONE.into(),
..default()
})
.with_children(|parent| {
Expand Down
4 changes: 0 additions & 4 deletions examples/ui/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
justify_content: JustifyContent::SpaceBetween,
..default()
},
background_color: Color::NONE.into(),
..default()
})
.with_children(|parent| {
Expand Down Expand Up @@ -130,7 +129,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
max_size: Size::UNDEFINED,
..default()
},
background_color: Color::NONE.into(),
..default()
},
ScrollingList::default(),
Expand Down Expand Up @@ -200,7 +198,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
justify_content: JustifyContent::Center,
..default()
},
background_color: Color::NONE.into(),
..default()
})
.with_children(|parent| {
Expand Down Expand Up @@ -283,7 +280,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
align_items: AlignItems::FlexEnd,
..default()
},
background_color: Color::NONE.into(),
..default()
})
.with_children(|parent| {
Expand Down
1 change: 0 additions & 1 deletion examples/window/scale_factor_override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
justify_content: JustifyContent::SpaceBetween,
..default()
},
background_color: Color::NONE.into(),
..default()
})
.with_children(|parent| {
Expand Down