Skip to content

Sprite picking docs fix #19016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions crates/bevy_sprite/src/picking_backend.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! A [`bevy_picking`] backend for sprites. Works for simple sprites and sprite atlases. Works for
//! sprites with arbitrary transforms. Picking is done based on sprite bounds, not visible pixels.
//! This means a partially transparent sprite is pickable even in its transparent areas.
//! sprites with arbitrary transforms.
//!
//! By default, picking for sprites is based on pixel opacity.
//! A sprite is picked only when a pointer is over an opaque pixel.
//! Alternatively, you can configure picking to be based on sprite bounds.
//!
//! ## Implementation Notes
//!
Expand Down Expand Up @@ -45,9 +48,10 @@ pub enum SpritePickingMode {
#[reflect(Resource, Default)]
pub struct SpritePickingSettings {
/// When set to `true` sprite picking will only consider cameras marked with
/// [`SpritePickingCamera`].
/// [`SpritePickingCamera`]. Defaults to `false`.
/// Regardless of this setting, only sprites marked with [`Pickable`] will be considered.
///
/// This setting is provided to give you fine-grained control over which cameras and entities
/// This setting is provided to give you fine-grained control over which cameras
/// should be used by the sprite picking backend at runtime.
pub require_markers: bool,
/// Should the backend count transparent pixels as part of the sprite for picking purposes or should it use the bounding box of the sprite alone.
Expand Down
4 changes: 2 additions & 2 deletions examples/picking/sprite_picking.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Demonstrates picking for sprites and sprite atlases. The picking backend only tests against the
//! sprite bounds, so the sprite atlas can be picked by clicking on its transparent areas.
//! Demonstrates picking for sprites and sprite atlases.
//! By default, the sprite picking backend considers a sprite only when a pointer is over an opaque pixel.

use bevy::{prelude::*, sprite::Anchor};
use std::fmt::Debug;
Expand Down