The dumbest and simplest layouting algorithm for bevy
The cuicui
framework is a collection of rust crates made for bevy.
cuicui_layout
: A dumb layout algorithm you can rely on, built for and with bevy.cuicui_dsl
and cuicui_chirp
: Two enjoyable ways to spawn scenes in bevy.For some reasons, the Cyberpunk main menu has become the 7GUI of bevy, so here
is the Cyberpunk main menu using cuicui_layout_bevy_ui
.
❗ Hot reloading disclaimer ❗ |
---|
Chirp hot reloading with bevy_ui
components (ie: using cuicui_layout_bevy_ui
)
is broken due to https://github.com/bevyengine/bevy/pull/9621.
You may want to work on a local patched version of bevy.
A workaround will probably be provided in cuicui 0.10.
The code for the video demo can be read in the chirpunk example.
A tinny example to get you an idea of what you can do with cuicui
.
Shows a blue box with cyan outline in the center of the screen:
use bevy::prelude::*;
use cuicui_layout::{dsl, LayoutRootCamera};
use cuicui_layout_bevy_ui::UiDsl as Dsl;
fn main() {
// Do not forget to add cuicui_layout_bevy_{ui,sprite}::Plugin
App::new()
.add_plugins((DefaultPlugins, cuicui_layout_bevy_ui::Plugin))
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
// Use LayoutRootCamera to mark a camera as the screen boundaries.
commands.spawn((Camera2dBundle::default(), LayoutRootCamera));
dsl! { &mut commands.spawn_empty(),
// Use screen_root to follow the screen's boundaries
Entity(row screen_root) {
// Stuff is centered by default.
Entity(row margin(9.) border(5, Color::CYAN) bg(Color::NAVY)) {
Entity(ui("Hello world!"))
}
}
};
}
Use the cargo run --bin
command to list possible examples, and run them.
We do this because it allows us to have different dependencies between examples.
cuicui_layout
The Usage section of the book is a good starting point.
Please read the Usage section of the book. Skip to the code if you don't care for explanations.
See the ./CHANGELOG.md file.
bevy | latest supporting version |
---|---|
0.12 | 0.12.0 |
0.11 | 0.10.2 |
0.10 | 0.3.0 |
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.