bevy_ui_style_builder

Crates.iobevy_ui_style_builder
lib.rsbevy_ui_style_builder
version0.2.3
sourcesrc
created_at2023-02-09 15:14:19.725944
updated_at2023-02-09 17:39:04.540258
descriptionExperimental Bevy UI helper extension methods.
homepage
repositoryhttps://github.com/ickshonpe/bevy_ui_style_builder
max_upload_size
id780803
size770,715
(ickshonpe)

documentation

README

bevy_ui_style_builder

crates.io MIT/Apache 2.0 crates.io

Experimental Bevy UI helper extension methods.

Supports Bevy 0.9

Usage

Add the dependency to your project:

cargo add bevy_ui_style_builder

Then the following example draws a red rectangle in the middle of the window:

use bevy::prelude::*;
use bevy_ui_style_builder::prelude::*;

fn spawn_example(
    mut commands: Commands,
) {
    commands.spawn(Camera2dBundle::default());
    commands.spawn(
        node()
        .width(Val::Percent(100.0))
        .height(Val::Percent(100.0))
        .justify_content_center()
        .align_items_center()
    ).with_children(|builder| {
        builder.spawn(
            node()
            .width(Val::Px(150.0))
            .height(Val::Px(100.0))
            .background_color(Color::RED)
        );
    });
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(spawn_example)
        .run();
}

There is a larger example based on Bevy's UI example in the examples folder. You can run it with:

cargo run --example ui
Commit count: 11

cargo fmt