diff --git a/crates/bevy_feathers/src/controls/color_slider.rs b/crates/bevy_feathers/src/controls/color_slider.rs index ad8b613b98d89..1dd1631d9906a 100644 --- a/crates/bevy_feathers/src/controls/color_slider.rs +++ b/crates/bevy_feathers/src/controls/color_slider.rs @@ -283,10 +283,10 @@ fn update_slider_pos( q_children: Query<&Children>, mut q_slider_thumb: Query<&mut Node, With>, ) { - for (slider_ent, value, range) in q_sliders.iter_mut() { + for (slider_ent, SliderValue(value), range) in q_sliders.iter_mut() { for child in q_children.iter_descendants(slider_ent) { if let Ok(mut thumb_node) = q_slider_thumb.get_mut(child) { - thumb_node.left = Val::Percent(range.thumb_position(value.0) * 100.0); + thumb_node.left = Val::Percent(range.thumb_position(*value) * 100.0); } } } diff --git a/examples/ui/feathers.rs b/examples/ui/feathers.rs index 59520af535a32..dae81bfef153c 100644 --- a/examples/ui/feathers.rs +++ b/examples/ui/feathers.rs @@ -368,11 +368,14 @@ fn demo_root() -> impl Scene { fn update_colors( colors: Res, - mut sliders: Query<(Entity, &ColorSlider, &mut SliderBaseColor)>, - swatches: Query<(&SwatchType, &Children), With>, + mut sliders: Query<(Entity, Ref, &mut SliderBaseColor)>, + swatches: Query<(Ref, &Children), With>, mut commands: Commands, ) { - if colors.is_changed() { + // Check to see if sliders or swatches were added after resource has changed. + let sliders_added = sliders.iter().any(|(_, slider, _)| slider.is_added()); + let swatches_added = swatches.iter().any(|(swatch, _)| swatch.is_added()); + if colors.is_changed() || sliders_added || swatches_added { for (slider_ent, slider, mut base) in sliders.iter_mut() { match slider.channel { ColorChannel::Red => { @@ -423,7 +426,7 @@ fn update_colors( for (swatch_type, children) in swatches.iter() { commands .entity(children[0]) - .insert(BackgroundColor(match swatch_type { + .insert(BackgroundColor(match *swatch_type { SwatchType::Rgb => colors.rgb_color.into(), SwatchType::Hsl => colors.hsl_color.into(), }));