I'm trying to create a component and system which adds a flashing animation to some bundles. I've the general idea, but I'm not sure the correct way to update the material color of the PBR in the system.
cursor.selection.debug_box_entity = Some(
commands
.spawn((PbrBundle {
material: materials.add(StandardMaterial {
alpha_mode: AlphaMode::Blend,
base_color: SELECTED_AREA_BOX_COLOR,
emissive: SELECTED_AREA_BOX_COLOR,
unlit: false,
..default()
}),
..default()
},))
.insert(Blinker {
timer: Timer::from_seconds(0.3, TimerMode::Once),
speed: 2.,
number_of_blinks: 2,
})
...
pub fn blink_system(
mut commands: Commands,
mut entities: Query<(Entity, &mut Blinker)>,
time: Res<Time>,
) {
for (entity, mut blinker) in &mut entities {
blinker.timer.tick(time.delta());
// Need to reference here to the material. 🤔
}
}
Sorry if I missed this in in the docs.