From f03876bdce78331f1ccb4351d71abb7a244d1734 Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Thu, 13 Jun 2024 11:57:08 -0700 Subject: [PATCH] Drag and drop proof of concept --- examples/drag_and_drop_ui.rs | 44 +++++++++++++++++++++++++++++++ src/editor.rs | 50 +++++++++++++++++++++++++++++++++--- src/game/dice.rs | 2 +- src/menu.rs | 1 + src/ui.rs | 12 ++++++++- 5 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 examples/drag_and_drop_ui.rs diff --git a/examples/drag_and_drop_ui.rs b/examples/drag_and_drop_ui.rs new file mode 100644 index 0000000..b812569 --- /dev/null +++ b/examples/drag_and_drop_ui.rs @@ -0,0 +1,44 @@ +use bevy::prelude::*; +use bevy_mod_picking::prelude::*; + +fn main() { + App::new() + .add_plugins(( + DefaultPlugins, + DefaultPickingPlugins, + )) + .add_systems(Startup, init_ui) + .run(); +} + +fn init_ui( + mut commands: Commands, +) { + commands.spawn(Camera3dBundle { ..default() }); + + commands.spawn(( + NodeBundle { + style: Style { + width: Val::Px(100.0), + height: Val::Px(100.0), + top: Val::Px(0.0), + left: Val::Px(0.0), + position_type: PositionType::Absolute, + ..default() + }, + background_color: Color::WHITE.into(), + ..default() + }, + PickableBundle::default(), + On::>::target_component_mut::