Unified picking cleanup (#18401)
# Objective @cart noticed some issues with my work in https://github.com/bevyengine/bevy/pull/17348#discussion_r2001815637, which I somehow missed before merging the PR. ## Solution - feature gate the UiPickingPlugin correctly - don't manually add the picking plugins ## Testing Ran the debug_picking and sprite_picking examples (for UI and sprites respectively): both seem to work fine.
This commit is contained in:
parent
62896aaf68
commit
8b6f48ca35
@ -35,7 +35,6 @@ pub use focus::*;
|
|||||||
pub use geometry::*;
|
pub use geometry::*;
|
||||||
pub use layout::*;
|
pub use layout::*;
|
||||||
pub use measurement::*;
|
pub use measurement::*;
|
||||||
use prelude::UiPickingPlugin;
|
|
||||||
pub use render::*;
|
pub use render::*;
|
||||||
pub use ui_material::*;
|
pub use ui_material::*;
|
||||||
pub use ui_node::*;
|
pub use ui_node::*;
|
||||||
@ -180,12 +179,14 @@ impl Plugin for UiPlugin {
|
|||||||
)
|
)
|
||||||
.chain(),
|
.chain(),
|
||||||
)
|
)
|
||||||
.add_plugins(UiPickingPlugin)
|
|
||||||
.add_systems(
|
.add_systems(
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
ui_focus_system.in_set(UiSystem::Focus).after(InputSystem),
|
ui_focus_system.in_set(UiSystem::Focus).after(InputSystem),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "bevy_ui_picking_backend")]
|
||||||
|
app.add_plugins(picking_backend::UiPickingPlugin);
|
||||||
|
|
||||||
let ui_layout_system_config = ui_layout_system
|
let ui_layout_system_config = ui_layout_system
|
||||||
.in_set(UiSystem::Layout)
|
.in_set(UiSystem::Layout)
|
||||||
.before(TransformSystem::TransformPropagate);
|
.before(TransformSystem::TransformPropagate);
|
||||||
|
@ -10,7 +10,7 @@ fn main() {
|
|||||||
filter: "bevy_dev_tools=trace".into(), // Show picking logs trace level and up
|
filter: "bevy_dev_tools=trace".into(), // Show picking logs trace level and up
|
||||||
..default()
|
..default()
|
||||||
}))
|
}))
|
||||||
.add_plugins((MeshPickingPlugin, DebugPickingPlugin, UiPickingPlugin))
|
.add_plugins((MeshPickingPlugin, DebugPickingPlugin))
|
||||||
.add_systems(Startup, setup_scene)
|
.add_systems(Startup, setup_scene)
|
||||||
.insert_resource(DebugPickingMode::Normal)
|
.insert_resource(DebugPickingMode::Normal)
|
||||||
// A system that cycles the debugging state when you press F3:
|
// A system that cycles the debugging state when you press F3:
|
||||||
|
@ -4,7 +4,7 @@ use bevy::prelude::*;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((DefaultPlugins, MeshPickingPlugin, UiPickingPlugin))
|
.add_plugins((DefaultPlugins, MeshPickingPlugin))
|
||||||
.add_systems(Startup, setup_scene)
|
.add_systems(Startup, setup_scene)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,7 @@ use std::fmt::Debug;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
|
||||||
DefaultPlugins.set(ImagePlugin::default_nearest()),
|
|
||||||
SpritePickingPlugin,
|
|
||||||
))
|
|
||||||
.add_systems(Startup, (setup, setup_atlas))
|
.add_systems(Startup, (setup, setup_atlas))
|
||||||
.add_systems(Update, (move_sprite, animate_sprite))
|
.add_systems(Update, (move_sprite, animate_sprite))
|
||||||
.run();
|
.run();
|
||||||
|
@ -31,7 +31,6 @@ fn main() {
|
|||||||
DefaultPlugins,
|
DefaultPlugins,
|
||||||
InputDispatchPlugin,
|
InputDispatchPlugin,
|
||||||
DirectionalNavigationPlugin,
|
DirectionalNavigationPlugin,
|
||||||
UiPickingPlugin,
|
|
||||||
))
|
))
|
||||||
// This resource is canonically used to track whether or not to render a focus indicator
|
// This resource is canonically used to track whether or not to render a focus indicator
|
||||||
// It starts as false, but we set it to true here as we would like to see the focus indicator
|
// It starts as false, but we set it to true here as we would like to see the focus indicator
|
||||||
|
@ -11,7 +11,7 @@ use bevy::{
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
app.add_plugins((DefaultPlugins, UiPickingPlugin))
|
app.add_plugins(DefaultPlugins)
|
||||||
.insert_resource(WinitSettings::desktop_app())
|
.insert_resource(WinitSettings::desktop_app())
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, update_scroll_position);
|
.add_systems(Update, update_scroll_position);
|
||||||
|
@ -12,12 +12,7 @@ use bevy::{
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((DefaultPlugins, InputDispatchPlugin, TabNavigationPlugin))
|
||||||
DefaultPlugins,
|
|
||||||
InputDispatchPlugin,
|
|
||||||
TabNavigationPlugin,
|
|
||||||
UiPickingPlugin,
|
|
||||||
))
|
|
||||||
// Only run the app when there is user input. This will significantly reduce CPU/GPU use.
|
// Only run the app when there is user input. This will significantly reduce CPU/GPU use.
|
||||||
.insert_resource(WinitSettings::desktop_app())
|
.insert_resource(WinitSettings::desktop_app())
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
|
Loading…
Reference in New Issue
Block a user