Fix debug ui

This commit is contained in:
rewin
2024-01-16 22:15:57 +03:00
parent e2cd421828
commit 657629f62a
5 changed files with 46 additions and 13 deletions
Generated
+8 -8
View File
@@ -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",
+1 -1
View File
@@ -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 = [
+18 -4
View File
@@ -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::<EditorPickingPlugin>()
.disable::<EditorDefaultCameraPlugin>()
.disable::<BottomMenuPlugin>()
.disable::<space_editor::space_editor_ui::ext::bevy_inspector_egui::quick::WorldInspectorPlugin>(),);
.disable::<GizmoToolPlugin>()
);
app.add_systems(Update, sync_editor_camera);
app.add_systems(Update, update_editor_ui_mode.run_if(resource_changed::<DebugMode>()));
}
}
fn toggle_debug_mode(mut input: EventReader<InputAction>, mut r_debug: ResMut<DebugMode>) {
fn toggle_debug_mode(
mut input: EventReader<InputAction>,
mut r_debug: ResMut<DebugMode>,) {
if input
.read()
.any(|action| matches!(action, InputAction(Lifecycle::Stop, Action::ToggleDebug)))
@@ -73,6 +77,16 @@ fn toggle_debug_mode(mut input: EventReader<InputAction>, mut r_debug: ResMut<De
}
}
fn update_editor_ui_mode(
r_debug: Res<DebugMode>,
mut s_show_editor_ui: ResMut<NextState<ShowEditorUi>>,
) {
s_show_editor_ui.set(match **r_debug {
true => ShowEditorUi::Show,
false => ShowEditorUi::Hide,
});
}
fn update_debug_picking_mode(
r_debug: Res<DebugMode>,
mut s_debug_picking: ResMut<NextState<DebugPickingMode>>,
+15
View File
@@ -38,3 +38,18 @@ pub(super) fn spawn_gizmo_camera(
));
});
}
pub(super) fn sync_gizmo_and_main_cameras(
q_main_camera: Query<&Camera, (With<MainCamera>, Without<GizmoCamera>)>,
mut q_gizmo_camera: Query<&mut Camera, (With<GizmoCamera>, Without<MainCamera>)>,
) {
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();
}
+4
View File
@@ -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),