bevy_nine_slice_ui 0.3.0

A nine slice texture plugin for bevy ui nodes
Documentation

Bevy nine slice/patch Material Plugin

Quick and easy auto-scaling nine slice/patch material for bevy ui nodes implemented as Fragment Shader.

cargo add bevy_nine_slice_ui

Usage

It's a single component.

app.add_plugin(NineSliceUiPlugin::default());
fn spawn_ui(mut cmd: Commands, server: Res<AssetServer>) {
    commands.spawn(NodeBundle {
        style: Style {
            width: Val::Percent(100.),
            height: Val::Percent(50.),
            display: Display::Flex,
            ..default()
        },
        ..default()
    })
    .insert(NineSliceTexture::from_image(server.load("panel.png")));
}

Using an atlas instead of a single image

Also added atlas capabilities. Instead of from_image, use from_slice method and pass the texture bounds.

.insert(NineSliceTexture::from_slice(
    server.load("panel_atlas.png"),
    Rect::new(0., 0., 32., 32.),
));

Check out the example

cargo run --example ui

result:

Example

Compatibility

  • Bevy 0.12