Add optional alpha / transparency passthrough for UI picking backend
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Optional transparency passthrough was added to the sprite picking backend in #16388.
## What solution would you like?
- I'd like to have the same capability for the UI picking backend. I have some decorative UI panels and I'd like avoid picking triggering when hovering their transparent areas.
- This was also hinted at in https://github.com/bevyengine/bevy/issues/14941#issuecomment-2313653684 but perhaps we forgot to add a tracking issue.
- As a bonus: Pending blessing, I'd consider the implementer doing a per-entity solution from day 1, so that you can mark some entities as using the alpha threshold, while others just inherit the global resource. If I had to guess, it doesn't seem much work adding that at the same time, but time will tell.
- Implementation to be verified but maybe spawning an entity with per-entity picking settings would look like this:
```rust
commands.spawn((
Node {
// ...
..Default::default()
},
ImageNode {
// ...
..Default::default()
},
ImagePickingSettings { picking_mode: ImagePickingMode::BoundingBox },
));
```
- Noting that, for the sprite picking backend, `SpritePickingSettings` defaults to `{ picking_mode: SpritePickingMode::AlphaThreshold(0.1) }` and so the example here is to illustrate that this entity is _overriding_ the OOTB alpha-threshold check to instead use a bounding-box check.
## What alternative(s) have you considered?
If you just have rounded buttons maybe #14957 already works for you, but it doesn't in my case.
Contributor guide
Research direction
Start by reading the sprite picking backend change in #16388 and compare it with the UI picking backend. Determine how a global alpha threshold and optional per-entity ImagePickingSettings should interact, then verify the behavior with UI panels that have transparent areas. Done means transparent UI regions no longer trigger picking when configured, while bounding-box behavior remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend, game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100