From 18b1bd8f9f0957d1cee8f03c8be27a43a7b86407 Mon Sep 17 00:00:00 2001 From: Tobias Berger Date: Sun, 4 Sep 2022 19:17:17 +0200 Subject: [PATCH] Simplify UI node layout --- src/main.rs | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6125a87..5297595 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,18 +41,13 @@ use bevy::{ change_detection::ResMut, system::{Commands, Res}, }, - hierarchy::BuildChildren, render::{ - color::Color, render_resource::{ Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages, }, texture::{Image, ImageSettings}, }, - ui::{ - entity::{ImageBundle, NodeBundle}, - Size, Style, UiImage, Val, - }, + ui::{entity::ImageBundle, Size, Style, UiImage, Val}, utils::default, window::WindowDescriptor, winit::WinitSettings, @@ -86,25 +81,14 @@ fn generate_texture( }); _ = commands.spawn_bundle(Camera2dBundle::default()); - _ = commands - .spawn_bundle(NodeBundle { - style: Style { - size: Size::new(Val::Percent(100.0), Val::Percent(100.0)), - ..default() - }, - color: Color::NONE.into(), + _ = commands.spawn_bundle(ImageBundle { + style: Style { + size: Size::new(Val::Auto, Val::Auto), ..default() - }) - .with_children(|parent| { - _ = parent.spawn_bundle(ImageBundle { - style: Style { - size: Size::new(Val::Percent(100.0), Val::Percent(100.0)), - ..default() - }, - image: UiImage(image_handle), - ..default() - }); - }); + }, + image: UiImage(image_handle), + ..default() + }); } fn main() -> Result<(), Box> {