Open alice-i-cecile opened 2 months ago
Correct me if I'm wrong but I think one use case for this is when you have rounded button images/sprites? For those, at least in my case, I don't want to trigger the interaction on the transparent pixels, i.e. only trigger interactions on clicks inside the round parts of the image. In that case, I'd agree I expected this behavior by default.
This issue is for the sprite picking backend, but is there any overlap with doing this for existing bevy UI buttons with images? I have some UI buttons with a UiImage
as its child, and I've wanted a way to avoid triggering interactions when clicking on the non-rounded parts. The sprite picking backend operates on Sprite
s only, so I don't expect this new picking backend to work for UiImage
s. It's fine if the answer is "that's a new issue", but I did wonder if they were somehow covered by the same approach.
For the case of rounded buttons specifically, we should be able to do a faster test. I agree that that should be on by default though. But yes, new issue please! It should be fixed in its own PR.
> Not sure what you mean by "test against alpha". Could you elaborate? EDIT - By that, do you mean whether or not the sprite is visible due to alpha/invisible texels? I'll add docs for that. Exactly. I think most users would expect fully transparent pixels to not be hittable. Might be something where the backend/component specifies a threshold, so any alpha below that value will be ignored. Doesn't need to be added right now, but would be nice to mention in the plugin docs.
Originally posted by @aevyrie in #14757 (comment)
We can either add a whole new backend for this, or add a configuration option to the existing backend. Checking the alpha value of each pixel is more expensive but more intuitive and should be enabled by default with a way to toggle it off.
Seconding this, it'd be very useful in the project I'm working on right now
Originally posted by @aevyrie in https://github.com/bevyengine/bevy/issues/14757#issuecomment-2297442070
We can either add a whole new backend for this, or add a configuration option to the existing backend. Checking the alpha value of each pixel is more expensive but more intuitive and should be enabled by default with a way to toggle it off.