Giter Club home page Giter Club logo

bevy_nine_slice_ui's Introduction

Hi, I am Lorenz, a passionate software developer from Germany. I enjoy Gamedev and Web, primarly in my favorite language Rust.

My current web goat: Nginx -> Axum -> Maud -> Htmx

For gamedev : Bevy Aseprite Blender

You can play some of my games on my website.

bevy_nine_slice_ui's People

Contributors

lommix avatar rparrett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

rparrett ganhaque

bevy_nine_slice_ui's Issues

Updating an entity's NineSliceTexture doesn't update the material.

Here's a reproducer that can be dropped in the examples directory.

Note that in the example below, I am only changing the texture, but this is also the case when switching between nine slices with the same texture but different bounds.

I am expecting the button to change visually when hovered.

use bevy::prelude::*;
use bevy_nine_slice_ui::prelude::*;

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, NineSlicePlugin::default()))
        .add_systems(Startup, setup)
        .add_systems(Update, button_system)
        .run();
}

fn button_system(
    mut commands: Commands,
    mut interaction_query: Query<(Entity, &Interaction), (Changed<Interaction>, With<Button>)>,
    server: Res<AssetServer>,
) {
    for (entity, interaction) in &mut interaction_query {
        match *interaction {
            Interaction::Hovered => {
                info!("Hovered.");
                commands.entity(entity).insert(NineSliceTexture::from_slice(
                    server.load("panel_atlas.png"),
                    Rect::new(0., 0., 32., 32.),
                ));
            }
            _ => {
                info!("Unhovered.");
                commands
                    .entity(entity)
                    .insert(NineSliceTexture::from_image(server.load("panel.png")));
            }
        }
    }
}

fn setup(mut commands: Commands, server: Res<AssetServer>) {
    commands.spawn(Camera2dBundle::default());
    commands
        .spawn(NodeBundle {
            style: Style {
                width: Val::Percent(100.0),
                height: Val::Percent(100.0),
                align_items: AlignItems::Center,
                justify_content: JustifyContent::Center,
                ..default()
            },
            ..default()
        })
        .with_children(|parent| {
            parent.spawn((
                ButtonBundle {
                    style: Style {
                        width: Val::Px(150.0),
                        height: Val::Px(65.0),
                        justify_content: JustifyContent::Center,
                        align_items: AlignItems::Center,
                        ..default()
                    },
                    ..default()
                },
                NineSliceTexture::from_image(server.load("panel.png")),
            ));
        });
}

Consider allowing an array of colors for palette shifting

I'm just now getting around to checking out the 0.5 update. Thanks for getting that out mid-jam, but I was too busy to even think about it.

Maybe this is only really useful for the very simple two-color graphics I was using and I haven't fully thought this through, but the main draw of the potential lookup gradient feature for me was dealing with fewer image assets. So the current implementation didn't seem worth using in my case.

Now that I'm thinking about this a little more though, I guess it would be super easy to build the palette assets in code, but I guess that's not the most intuitive API.

If you've already considered this, then I consider the issue resolved, so feel free to close.

All of Bevy's default features aren't required

Hi, thanks for publishing this. It's the first crate I've seen making use of the new UI materials and seems quite handy!

Cargo features are additive, so adding bevy_nine_slice_ui to my project means that I need to compile bevy_pbr, bevy_gltf, bevy_animation, and other features that my 2d project doesn't need.

This also makes it impossible to do webgpu builds, because the webgl2 feature is included by default.

It would be great if you could pare down to only the features required to make bevy_nine_slice_ui function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.