Crates.io | bevy_ui_builder |
lib.rs | bevy_ui_builder |
version | 0.1.0 |
source | src |
created_at | 2023-01-30 13:47:40.763616 |
updated_at | 2023-01-30 13:47:40.763616 |
description | ui builder library for bevy_ui |
homepage | https://github.com/gavxin/bevy_ui_builder |
repository | https://github.com/gavxin/bevy_ui_builder |
max_upload_size | |
id | 771824 |
size | 152,773 |
Simple ui builder, a simple wrapper of bevy_ui, fluent api design.
Under heavy development, cannot guarantee API stability.
before start, you need to know about bevy_ui 4 basic ui elements
ui builder has corresponding functions to build entire ui
// before start, add plugin first
.add_plugin(UiBuilderPlugin)
// usage
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// ...
let mut b = UiBuilder::new(&mut commands, ());
// create new node element
b.node()
// style modifier
.with_style_modifier((StyleSize::FULL, StyleCenterChildren))
.with_children(|b| {
// create image element
b.image(asset_server.load("image/file.png"));
// create button element
b.button()
.with_children(|b| {
// create text element
b.text("text content");
});
});
// ...
}
Style
component with .with_style_modifiers(...)
Text
component with .with_text_modifier(...)
Visibility
component with .with_visibility(...)
BackgroundColor
component with .with_bg_color(...)
NOTE: duplicated call will overwrite previous state
For more StyleModifier
and TextModifier
, please see src/modifiers.rs
There is a button example
.with_toggle(false)
.with_toggle(false).with_toggle_group("group_name")
.with_action_on_release()
: action performed on mouse button release inside.with_mouse_button_mask(...)
: react on additional mouse right / middle button, or can disable default left mouse buttonevery button has following visual states,
library provide following two ways
.with_image_button()
: change UiImage when visual state change..with_color_button()
: change BackgroundColor when visual state change.If you need more customize style, you can use Changed<>
subscribe ButtonVisualState
component changes, and work on your styles.
S
T
api | description |
---|---|
with_bind_source::<S, T>(source, handler) |
when remote entity source component S change, call handler function to modify current entity component T . see example |
with_on_self_change::<S>(handler) |
when current entity component S change, call handler function. see example |
with_event_bind_to_target::<E, T>(target, handler) |
when event E happen, call handler function to modify entity target component T . see example |
with_on_source_change::<S>(source, handler) |
when remote entity source component S change, call handler function. see example |
with_self_bind::<S, T>(handler) |
when current entity component S change, call handler function to modify current entity component T . see example |
with_bind_to_target::<S, T>(target, handler) |
when current entity component S change, call handler function to modify remote entity target component T . see example |
with_bind_to_multiple_targets::<S, T>(binds) |
when current entity component S change, call handler function to modify remote entity target component T |
bevy | bevy_ui_builder |
---|---|
0.9 | 0.1 |
This library is inspired from following libraries
MIT OR Apache-2.0