I'm unfamiliar with the general way of changing the defaults, and diving into the source code of the bevy_mod_picking
library didn't reveal any obvious answers for me (a newcomer to rust).
I would like to change the highlighted colours of the picked/selected mesh. I got this far:
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: set_size*1.2 })),
material: transparent_material,
transform: Transform::from_xyz(0.0, 1.0, 0.0),
..default()
}).insert_bundle(PickableBundle{
highlight: highlight::Highlight {
// how to change this to a transparent colour?
..default()
},
..default()
});
Looking into the highlighting.rs
or the bevy_mod_picking
library, I see this line:
/// Marker component to flag an entity as highlightable
#[derive(Component, Clone, Debug, Default)]
pub struct Highlight;
However, the word "Highlight" doesn't appear in any further code leaving me wondering as to what to do next to modify the colours. There are some default colours defined further down, but they use different structs such as Highlightable
, so I was quite lost after that. I would like to have a transparent colour as I don't want to see the highlighting at all in my use case.
Would be good to get an answer on the above + provide some kind of reference to this coding pattern for future reference.
Seems immediately after I've asked here, somehow the answer magically came to me via a reddit post.
This is the modified code that does what I want:
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane { size: set_size*1.2 })),
material: transparent_material.clone(),
transform: Transform::from_xyz(0.0, 1.0, 0.0),
..default()
}).insert_bundle(PickableBundle{
highlight: highlight::Highlight {
..default()
},
..default()
}).insert(Highlighting{
initial: transparent_material.clone(),
hovered: Some(transparent_material.clone()),
pressed: Some(transparent_material.clone()),
selected:Some(transparent_material.clone()),
});
I haven't learnt anything of course so if a question with an explanation comes along then I'll accept it over this one.