ui layout testing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy::{prelude::*, sprite::Anchor};
|
||||
use bevy_lunex::prelude::*;
|
||||
|
||||
pub struct BuildUiPlugin;
|
||||
@@ -22,13 +22,42 @@ fn setup_ui(mut commands: Commands, assets: Res<AssetServer>, mut material: ResM
|
||||
.with_children(|ui| {
|
||||
ui.spawn((
|
||||
UiLink::<MainUi>::path("Root"),
|
||||
UiLayout::boundary().pos1(Rl(20.0)).pos2(Rl(80.0)).pack::<Base>(),
|
||||
UiLayout::boundary()
|
||||
.pos1((Rl(0.), Rl(0.)))
|
||||
.pos2((Rl(100.), Rl(100.)))
|
||||
.pack::<Base>(),
|
||||
));
|
||||
|
||||
ui.spawn((
|
||||
UiLink::<MainUi>::path("Root/Rect"),
|
||||
UiLayout::solid().size((Ab(1920.0), Ab(1080.0))).pack::<Base>(),
|
||||
UiLink::<MainUi>::path("Root/MainRect"),
|
||||
UiLayout::window()
|
||||
.anchor(Anchor::BottomCenter)
|
||||
.size((Ab(800.), Rl(100.)))
|
||||
.pos((Rl(50.), Rl(100.)))
|
||||
.pack::<Base>(),
|
||||
));
|
||||
|
||||
ui.spawn((
|
||||
UiLink::<MainUi>::path("Root/MainRect/Categories"),
|
||||
UiLayout::solid()
|
||||
.align_y(Align::END)
|
||||
.size((Rl(100.), Ab(30.)))
|
||||
.pack::<Base>(),
|
||||
));
|
||||
|
||||
for i in 1..5 {
|
||||
let path = format!("Root/MainRect/Categories/Button{}", i);
|
||||
ui.spawn((
|
||||
UiLink::<MainUi>::path(path),
|
||||
UiLayout::div()
|
||||
.margin_x(Ab(5.))
|
||||
.height(Sizing::Max)
|
||||
.min_height(Ab(30.))
|
||||
.min_width(Sp(10.))
|
||||
.max_width(Sp(100.))
|
||||
.pack::<Base>(),
|
||||
UiImage2dBundle::from(assets.load("textures/world/test2.png")),
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ impl Plugin for EditorPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<UIState>();
|
||||
|
||||
app.add_systems(PostUpdate, prepare_image.run_if(in_state(GeneratorState::SpawnMap)));
|
||||
app.add_systems(
|
||||
Update,
|
||||
(render_map_ui, update_map_render, asset_reloaded).run_if(in_state(GeneratorState::Idle)),
|
||||
);
|
||||
// app.add_systems(PostUpdate, prepare_image.run_if(in_state(GeneratorState::SpawnMap)));
|
||||
// app.add_systems(
|
||||
// Update,
|
||||
// (render_map_ui, update_map_render, asset_reloaded).run_if(in_state(GeneratorState::Idle)),
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ fn asset_reloaded(
|
||||
let mut rebuild = false;
|
||||
for event in asset_events.read() {
|
||||
match event {
|
||||
AssetEvent::Modified {..}=> rebuild = true,
|
||||
AssetEvent::Modified { .. } => rebuild = true,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user