Sprite picking docs fix (#19016)

# Objective

- Docs in sprite picking plugin / example contain outdated information.

References:
- Sprite picking now always require `Picking` - #17842
- Transparency pass-through added - #16388

## Solution

- Fix the docs.
This commit is contained in:
akimakinai 2025-05-06 02:45:14 +09:00 committed by GitHub
parent 113d1b7dc1
commit 0f6d532a15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,9 @@
//! A [`bevy_picking`] backend for sprites. Works for simple sprites and sprite atlases. Works for //! 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. //! sprites with arbitrary transforms.
//! This means a partially transparent sprite is pickable even in its transparent areas. //!
//! 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 //! ## Implementation Notes
//! //!
@ -45,9 +48,10 @@ pub enum SpritePickingMode {
#[reflect(Resource, Default)] #[reflect(Resource, Default)]
pub struct SpritePickingSettings { pub struct SpritePickingSettings {
/// When set to `true` sprite picking will only consider cameras marked with /// 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. /// should be used by the sprite picking backend at runtime.
pub require_markers: bool, 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. /// 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.

View File

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