Simplify UI node layout
This commit is contained in:
parent
845b13650a
commit
18b1bd8f9f
1 changed files with 8 additions and 24 deletions
22
src/main.rs
22
src/main.rs
|
@ -41,18 +41,13 @@ use bevy::{
|
||||||
change_detection::ResMut,
|
change_detection::ResMut,
|
||||||
system::{Commands, Res},
|
system::{Commands, Res},
|
||||||
},
|
},
|
||||||
hierarchy::BuildChildren,
|
|
||||||
render::{
|
render::{
|
||||||
color::Color,
|
|
||||||
render_resource::{
|
render_resource::{
|
||||||
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
|
Extent3d, TextureDescriptor, TextureDimension, TextureFormat, TextureUsages,
|
||||||
},
|
},
|
||||||
texture::{Image, ImageSettings},
|
texture::{Image, ImageSettings},
|
||||||
},
|
},
|
||||||
ui::{
|
ui::{entity::ImageBundle, Size, Style, UiImage, Val},
|
||||||
entity::{ImageBundle, NodeBundle},
|
|
||||||
Size, Style, UiImage, Val,
|
|
||||||
},
|
|
||||||
utils::default,
|
utils::default,
|
||||||
window::WindowDescriptor,
|
window::WindowDescriptor,
|
||||||
winit::WinitSettings,
|
winit::WinitSettings,
|
||||||
|
@ -86,25 +81,14 @@ fn generate_texture(
|
||||||
});
|
});
|
||||||
|
|
||||||
_ = commands.spawn_bundle(Camera2dBundle::default());
|
_ = commands.spawn_bundle(Camera2dBundle::default());
|
||||||
_ = commands
|
_ = commands.spawn_bundle(ImageBundle {
|
||||||
.spawn_bundle(NodeBundle {
|
|
||||||
style: Style {
|
style: Style {
|
||||||
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
|
size: Size::new(Val::Auto, Val::Auto),
|
||||||
..default()
|
|
||||||
},
|
|
||||||
color: Color::NONE.into(),
|
|
||||||
..default()
|
|
||||||
})
|
|
||||||
.with_children(|parent| {
|
|
||||||
_ = parent.spawn_bundle(ImageBundle {
|
|
||||||
style: Style {
|
|
||||||
size: Size::new(Val::Percent(100.0), Val::Percent(100.0)),
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
image: UiImage(image_handle),
|
image: UiImage(image_handle),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
Loading…
Reference in a new issue