Repository navigation
Is there a support for state-based styling in bevy_ui ? #26311
Replies: 1 comment
|
There's no declarative, CSS-style "state → style" system in State components
Styling pattern Query for changes and set the colour, as Untested sketch (not compiled): fn style_buttons(
mut q: Query<(&mut BackgroundColor, &Hovered, Has<Pressed>, Has<InteractionDisabled>),
Or<(Changed<Hovered>, Added<Pressed>, Added<InteractionDisabled>)>>,
) {
for (mut bg, hovered, pressed, disabled) in &mut q {
bg.0 = match (disabled, pressed, hovered.get()) {
(true, _, _) => DISABLED, (_, true, _) => PRESSED,
(_, _, true) => HOVER, _ => NORMAL,
};
}
}(Add a system for the removal case, as feathers does.) Ready-made options
Note: this is based on current |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
All reactions