You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a tween spawned like this to animate the alpha of a mesh. This works.
let material =
materials.add(ColorMaterial::from(OWN_COLOR_DEFAULT.with_alpha(0.)));
parent.spawn((Mesh2d(
meshes.add(Annulus::new(planet.size()*0.55, planet.size()*0.57)),),MeshMaterial2d(material.clone()),Transform::from_xyz(0.,0.,0.6),TweenAnim::new(Tween::new(EaseFunction::SineInOut,Duration::from_secs(2),ColorMaterialColorLens{start:OWN_COLOR_DEFAULT.with_alpha(0.),end:OWN_COLOR_DEFAULT.with_alpha(1.),},).with_repeat_count(RepeatCount::Infinite).with_repeat_strategy(RepeatStrategy::MirroredRepeat),),AnimTarget::asset(&material),Visibility::Hidden,PlanetaryShieldCmp,));
However, I want to change the color of the annulus when the player hovers over something. I have this code in a system:
ifletOk((mut visibility,mut tween)) = ps_q.get_mut(child){*visibility = if has_ps {let color = if selected {OWN_COLOR_HOVER}else{OWN_COLOR_DEFAULT};*tween = TweenAnim::new(Tween::new(EaseFunction::SineInOut,Duration::from_secs(2),ColorMaterialColorLens{start: color.with_alpha(0.),end: color.with_alpha(1.),},).with_repeat_count(RepeatCount::Infinite).with_repeat_strategy(RepeatStrategy::MirroredRepeat),);Visibility::Inherited}else{Visibility::Hidden}}
but then nothing shows.
I also tried this
ifletOk((mut visibility, tween)) = ps_q.get_mut(child){*visibility = if has_ps {ifletSome(material) = materials.get_mut(&*ps_m){
material.color = if selected {OWN_COLOR_HOVER.with_alpha(0.)}else{OWN_COLOR_DEFAULT.with_alpha(0.)};}Visibility::Inherited}else{Visibility::Hidden}}
which works when I remove the animation, but doesn't work with the tween.
How can I make the color of the twee change? Thanks
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I have a tween spawned like this to animate the alpha of a mesh. This works.
However, I want to change the color of the annulus when the player hovers over something. I have this code in a system:
but then nothing shows.
I also tried this
which works when I remove the animation, but doesn't work with the tween.
How can I make the color of the twee change? Thanks
All reactions