diff --git a/Cargo.lock b/Cargo.lock index b305ccd..d1a98a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3787,7 +3787,7 @@ dependencies = [ [[package]] name = "space_bevy_xpbd_plugin" version = "0.3.1" -source = "git+https://github.com/rewin123/space_editor?rev=ac8651f4d8f916566e1026b04d03d1ed476fc610#ac8651f4d8f916566e1026b04d03d1ed476fc610" +source = "git+https://github.com/rewin123/space_editor?rev=b56d81222cbf59448ecda5064bf1b37ca90b84f1#b56d81222cbf59448ecda5064bf1b37ca90b84f1" dependencies = [ "bevy", "bevy_xpbd_3d", @@ -3797,7 +3797,7 @@ dependencies = [ [[package]] name = "space_editor" version = "0.3.1" -source = "git+https://github.com/rewin123/space_editor?rev=ac8651f4d8f916566e1026b04d03d1ed476fc610#ac8651f4d8f916566e1026b04d03d1ed476fc610" +source = "git+https://github.com/rewin123/space_editor?rev=b56d81222cbf59448ecda5064bf1b37ca90b84f1#b56d81222cbf59448ecda5064bf1b37ca90b84f1" dependencies = [ "bevy", "space_bevy_xpbd_plugin", @@ -3808,7 +3808,7 @@ dependencies = [ [[package]] name = "space_editor_core" version = "0.3.1" -source = "git+https://github.com/rewin123/space_editor?rev=ac8651f4d8f916566e1026b04d03d1ed476fc610#ac8651f4d8f916566e1026b04d03d1ed476fc610" +source = "git+https://github.com/rewin123/space_editor?rev=b56d81222cbf59448ecda5064bf1b37ca90b84f1#b56d81222cbf59448ecda5064bf1b37ca90b84f1" dependencies = [ "bevy", "space_persistence", @@ -3820,7 +3820,7 @@ dependencies = [ [[package]] name = "space_editor_ui" version = "0.3.1" -source = "git+https://github.com/rewin123/space_editor?rev=ac8651f4d8f916566e1026b04d03d1ed476fc610#ac8651f4d8f916566e1026b04d03d1ed476fc610" +source = "git+https://github.com/rewin123/space_editor?rev=b56d81222cbf59448ecda5064bf1b37ca90b84f1#b56d81222cbf59448ecda5064bf1b37ca90b84f1" dependencies = [ "bevy", "bevy_debug_grid", @@ -3841,7 +3841,7 @@ dependencies = [ [[package]] name = "space_persistence" version = "0.3.1" -source = "git+https://github.com/rewin123/space_editor?rev=ac8651f4d8f916566e1026b04d03d1ed476fc610#ac8651f4d8f916566e1026b04d03d1ed476fc610" +source = "git+https://github.com/rewin123/space_editor?rev=b56d81222cbf59448ecda5064bf1b37ca90b84f1#b56d81222cbf59448ecda5064bf1b37ca90b84f1" dependencies = [ "bevy", "ron", @@ -3851,7 +3851,7 @@ dependencies = [ [[package]] name = "space_prefab" version = "0.3.1" -source = "git+https://github.com/rewin123/space_editor?rev=ac8651f4d8f916566e1026b04d03d1ed476fc610#ac8651f4d8f916566e1026b04d03d1ed476fc610" +source = "git+https://github.com/rewin123/space_editor?rev=b56d81222cbf59448ecda5064bf1b37ca90b84f1#b56d81222cbf59448ecda5064bf1b37ca90b84f1" dependencies = [ "bevy", "bevy-inspector-egui", @@ -3865,7 +3865,7 @@ dependencies = [ [[package]] name = "space_shared" version = "0.3.1" -source = "git+https://github.com/rewin123/space_editor?rev=ac8651f4d8f916566e1026b04d03d1ed476fc610#ac8651f4d8f916566e1026b04d03d1ed476fc610" +source = "git+https://github.com/rewin123/space_editor?rev=b56d81222cbf59448ecda5064bf1b37ca90b84f1#b56d81222cbf59448ecda5064bf1b37ca90b84f1" dependencies = [ "bevy", "bevy-inspector-egui", @@ -3875,7 +3875,7 @@ dependencies = [ [[package]] name = "space_undo" version = "0.3.1" -source = "git+https://github.com/rewin123/space_editor?rev=ac8651f4d8f916566e1026b04d03d1ed476fc610#ac8651f4d8f916566e1026b04d03d1ed476fc610" +source = "git+https://github.com/rewin123/space_editor?rev=b56d81222cbf59448ecda5064bf1b37ca90b84f1#b56d81222cbf59448ecda5064bf1b37ca90b84f1" dependencies = [ "bevy", "pretty-type-name", diff --git a/studio/Cargo.toml b/studio/Cargo.toml index 6980b8d..cbf98c3 100644 --- a/studio/Cargo.toml +++ b/studio/Cargo.toml @@ -32,7 +32,7 @@ web-sys = { version = "0.3.65", optional = true, features = [ "HtmlElement", "Window", ] } -space_editor = {git = "https://github.com/rewin123/space_editor", rev = "ac8651f4d8f916566e1026b04d03d1ed476fc610"} +space_editor = {git = "https://github.com/rewin123/space_editor", rev = "b56d81222cbf59448ecda5064bf1b37ca90b84f1"} [features] wasm = [ diff --git a/studio/src/debug.rs b/studio/src/debug.rs index 2fd74fc..b14bd4b 100644 --- a/studio/src/debug.rs +++ b/studio/src/debug.rs @@ -3,7 +3,7 @@ use std::fmt; use bevy::{prelude::*, window::PrimaryWindow}; use bevy_inspector_egui::{quick::WorldInspectorPlugin, bevy_egui::EguiPlugin, DefaultInspectorConfigPlugin}; use bevy_mod_picking::debug::DebugPickingMode; -use space_editor::{space_editor_ui::{EditorPluginGroup, EditorPickingPlugin, EditorDefaultCameraPlugin, bottom_menu::BottomMenuPlugin, EditorUiCore}, prelude::{EditorCameraMarker, space_undo::UndoPlugin}}; +use space_editor::{space_editor_ui::{EditorPluginGroup, EditorPickingPlugin, EditorDefaultCameraPlugin, bottom_menu::BottomMenuPlugin, EditorUiCore, tools::gizmo::GizmoToolPlugin, ShowEditorUi}, prelude::{EditorCameraMarker, space_undo::UndoPlugin}}; use crate::{ camera_controller::{CameraController, CameraMotionSystem}, @@ -24,7 +24,6 @@ pub struct DebugPlugin; impl Plugin for DebugPlugin { fn build(&self, app: &mut App) { app.insert_resource(DebugMode(false)) - .add_plugins(WorldInspectorPlugin::new().run_if(is_debug_mode)) .insert_resource(State::new(DebugPickingMode::Disabled)) .insert_resource(GizmoConfig { enabled: true, @@ -44,6 +43,7 @@ impl Plugin for DebugPlugin { .run_if(is_debug_mode), ), ); + //space_editor stuff // app.add_plugins(UndoPlugin); @@ -58,13 +58,17 @@ impl Plugin for DebugPlugin { .disable::() .disable::() .disable::() - .disable::(),); + .disable::() + ); app.add_systems(Update, sync_editor_camera); + app.add_systems(Update, update_editor_ui_mode.run_if(resource_changed::())); } } -fn toggle_debug_mode(mut input: EventReader, mut r_debug: ResMut) { +fn toggle_debug_mode( + mut input: EventReader, + mut r_debug: ResMut,) { if input .read() .any(|action| matches!(action, InputAction(Lifecycle::Stop, Action::ToggleDebug))) @@ -73,6 +77,16 @@ fn toggle_debug_mode(mut input: EventReader, mut r_debug: ResMut, + mut s_show_editor_ui: ResMut>, +) { + s_show_editor_ui.set(match **r_debug { + true => ShowEditorUi::Show, + false => ShowEditorUi::Hide, + }); +} + fn update_debug_picking_mode( r_debug: Res, mut s_debug_picking: ResMut>, diff --git a/studio/src/interaction/gizmos/camera.rs b/studio/src/interaction/gizmos/camera.rs index 6c01cac..ea45aad 100644 --- a/studio/src/interaction/gizmos/camera.rs +++ b/studio/src/interaction/gizmos/camera.rs @@ -38,3 +38,18 @@ pub(super) fn spawn_gizmo_camera( )); }); } + +pub(super) fn sync_gizmo_and_main_cameras( + q_main_camera: Query<&Camera, (With, Without)>, + mut q_gizmo_camera: Query<&mut Camera, (With, Without)>, +) { + let Ok(main_cam) = q_main_camera.get_single() else { + return; + }; + + let Ok(mut gizmo_cam) = q_gizmo_camera.get_single_mut() else { + return; + }; + + gizmo_cam.viewport = main_cam.viewport.clone(); +} diff --git a/studio/src/interaction/gizmos/mod.rs b/studio/src/interaction/gizmos/mod.rs index 1c06515..b3eb1ea 100644 --- a/studio/src/interaction/gizmos/mod.rs +++ b/studio/src/interaction/gizmos/mod.rs @@ -62,6 +62,10 @@ impl Plugin for GizmoPlugin { normalize_gizmo_scale.after(CameraMotionSystem), ), ); + + //sync camera viewports + app.add_systems(Update, camera::sync_gizmo_and_main_cameras); + app.add_systems( PostUpdate, update_ss_ring_rotation.after(TransformSystem::TransformPropagate),