diff --git a/Cargo.toml b/Cargo.toml index 0251c2b..48ecfd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["./studio"] [workspace.dependencies.bevy] -version = "0.12.0" +version = "0.12.1" features = ["tonemapping_luts"] [profile.dev-custom] diff --git a/studio/Cargo.toml b/studio/Cargo.toml index 1b8bc33..a8d7161 100644 --- a/studio/Cargo.toml +++ b/studio/Cargo.toml @@ -32,6 +32,7 @@ web-sys = { version = "0.3.65", optional = true, features = [ "HtmlElement", "Window", ] } +space_editor = {git = "https://github.com/rewin123/space_editor", rev = "f039601b6d286a5f9e3b09521623000d5bf3eb84"} [features] wasm = [ diff --git a/studio/src/input.rs b/studio/src/input.rs index 962c5bc..097c0a0 100644 --- a/studio/src/input.rs +++ b/studio/src/input.rs @@ -3,6 +3,7 @@ use bevy::{ prelude::*, utils::HashSet, }; +use space_editor::prelude::space_undo::UndoRedo; #[derive(SystemSet, Hash, Debug, PartialEq, Eq, Clone)] pub struct StudioInputSystem; @@ -18,6 +19,7 @@ impl Plugin for StudioInputPlugin { translate_debug_toggle, translate_dcc_camera_events, translate_fps_camera_events, + send_undo_event ) .in_set(StudioInputSystem) .after(bevy::input::InputSystem), @@ -291,3 +293,15 @@ fn read_mouse_delta(mut mouse_motion: EventReader) -> Vec2 { .read() .fold(Vec2::ZERO, |accum, current| accum + current.delta) } + + +// TODO: Make it configurable +fn send_undo_event( + mut events : EventWriter, + keyboard: Res>, +) { + if keyboard.pressed(KeyCode::ControlLeft) && keyboard.just_pressed(KeyCode::Z) { + events.send(UndoRedo::Undo); + info!("Undo event sent"); + } +} \ No newline at end of file diff --git a/studio/src/scene.rs b/studio/src/scene.rs index b4cc5c0..480f702 100644 --- a/studio/src/scene.rs +++ b/studio/src/scene.rs @@ -13,6 +13,7 @@ use bevy::{ scene::InstanceId, }; +use space_editor::prelude::PrefabMarker; #[cfg(feature = "wasm")] use wasm_bindgen::prelude::wasm_bindgen; @@ -207,6 +208,7 @@ fn spawn_next_scene( SceneRoot, SceneElement, SpatialBundle::default(), + PrefabMarker )) .id(); @@ -254,7 +256,7 @@ fn tag_scene_elements( }; if gltf.named_nodes.contains_key(&**name) { - cmd.entity(ent).insert(SceneElement); + cmd.entity(ent).insert(SceneElement).insert(PrefabMarker); } } }