Skip to content

Commit f8dd8c3

Browse files
akimakinaiandrewzhurov
authored andcommitted
Sprite picking docs fix (bevyengine#19016)
# Objective - Docs in sprite picking plugin / example contain outdated information. References: - Sprite picking now always require `Picking` - bevyengine#17842 - Transparency pass-through added - bevyengine#16388 ## Solution - Fix the docs.
1 parent 4ce9aa6 commit f8dd8c3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

crates/bevy_sprite/src/picking_backend.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! A [`bevy_picking`] backend for sprites. Works for simple sprites and sprite atlases. Works for
2-
//! sprites with arbitrary transforms. Picking is done based on sprite bounds, not visible pixels.
3-
//! This means a partially transparent sprite is pickable even in its transparent areas.
2+
//! sprites with arbitrary transforms.
3+
//!
4+
//! By default, picking for sprites is based on pixel opacity.
5+
//! A sprite is picked only when a pointer is over an opaque pixel.
6+
//! Alternatively, you can configure picking to be based on sprite bounds.
47
//!
58
//! ## Implementation Notes
69
//!
@@ -45,9 +48,10 @@ pub enum SpritePickingMode {
4548
#[reflect(Resource, Default)]
4649
pub struct SpritePickingSettings {
4750
/// When set to `true` sprite picking will only consider cameras marked with
48-
/// [`SpritePickingCamera`].
51+
/// [`SpritePickingCamera`]. Defaults to `false`.
52+
/// Regardless of this setting, only sprites marked with [`Pickable`] will be considered.
4953
///
50-
/// This setting is provided to give you fine-grained control over which cameras and entities
54+
/// This setting is provided to give you fine-grained control over which cameras
5155
/// should be used by the sprite picking backend at runtime.
5256
pub require_markers: bool,
5357
/// 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.

examples/picking/sprite_picking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//! Demonstrates picking for sprites and sprite atlases. The picking backend only tests against the
2-
//! sprite bounds, so the sprite atlas can be picked by clicking on its transparent areas.
1+
//! Demonstrates picking for sprites and sprite atlases.
2+
//! By default, the sprite picking backend considers a sprite only when a pointer is over an opaque pixel.
33
44
use bevy::{prelude::*, sprite::Anchor};
55
use std::fmt::Debug;

0 commit comments

Comments
 (0)