Crates.io | bevy_ui_bits |
lib.rs | bevy_ui_bits |
version | 0.3.0 |
source | src |
created_at | 2023-02-21 20:45:36.201983 |
updated_at | 2023-07-12 06:29:52.901287 |
description | A mingy and opinionated collection of UI components for Bevy |
homepage | https://github.com/septum/bevy_ui_bits |
repository | https://github.com/septum/bevy_ui_bits |
max_upload_size | |
id | 791045 |
size | 113,313 |
A mingy and opinionated collection of UI components for Bevy
use bevy::prelude::*;
use bevy_ui_bits::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(spawn_ui)
.run();
}
fn spawn_ui(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
let font = &asset_server.load("fonts/FiraMono-Medium.ttf");
// Root is the encompassing component for a given UI tree
let root = Root::congregated();
// Container is the quintessential layout component
let mut main_container = Container::height(400.0);
// EmbossedText represents text with a background relief
let mut title = EmbossedText::large("My Game", font);
// UiButton wraps over a ButtonBundle with opinionated defaults
let mut play = UiButton::new("Start", font);
let by = SimpleText::small("By me", font);
// Make changes to the properties with a fluent interface
main_container.justify_between();
title.color(Color::MIDNIGHT_BLUE);
play.selected_color(Color::MIDNIGHT_BLUE);
// Use a nested structure to spawn the UI tree
root.spawn(&mut commands, |parent| {
main_container.spawn(parent, |parent| {
title.spawn(parent);
play.spawn(parent);
by.spawn(parent);
});
});
}
Try it out with:
cargo run --example main_menu --features="bevy/default"
Try it out with:
cargo run --example hud --features="bevy/default"
RootMarker
Try it out with:
cargo run --example despawn --features="bevy/default"
bevy | bevy_ui_bits |
---|---|
0.11 | 0.3 |
0.10 | 0.2 |
0.9 | 0.1 |
This project is dual-licensed under either:
at your option.
With the exception of the Fira Mono Font, which has its own license.
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.