Debug rect
This commit is contained in:
parent
86909e8bcb
commit
28765e173a
31
src/ui/editor/camera.rs
Normal file
31
src/ui/editor/camera.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use bevy::{prelude::*, window::PrimaryWindow, render::camera::Viewport};
|
||||
use bevy_inspector_egui::bevy_egui;
|
||||
|
||||
use crate::comps::core::markers::camera::MainCamera;
|
||||
|
||||
pub fn set_camera_viewport(
|
||||
primary_window: Query<&mut Window, With<PrimaryWindow>>,
|
||||
egui_settings: Res<bevy_egui::EguiSettings>,
|
||||
mut cameras: Query<&mut Camera, With<MainCamera>>,
|
||||
) {
|
||||
let Ok(mut cam) = cameras.get_single_mut() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(window) = primary_window.get_single() else {
|
||||
return;
|
||||
};
|
||||
|
||||
println!("{}, {}", window.width(), window.height());
|
||||
|
||||
let scale_factor = window.scale_factor() * egui_settings.scale_factor;
|
||||
|
||||
/*let viewport_pos = ui_state.viewport_rect.left_top().to_vec2() * scale_factor as f32;
|
||||
let viewport_size = ui_state.viewport_rect.size() * scale_factor as f32;
|
||||
|
||||
cam.viewport = Some(Viewport {
|
||||
physical_position: UVec2::new(viewport_pos.x as u32, viewport_pos.y as u32),
|
||||
physical_size: UVec2::new(viewport_size.x as u32, viewport_size.y as u32),
|
||||
depth: 0.0..1.0,
|
||||
});*/
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
//! Editor UI means everything that won't be in the actual game
|
||||
pub mod plugin;
|
||||
pub mod panels;
|
||||
pub mod state;
|
||||
pub mod state;
|
||||
pub mod camera;
|
@ -20,15 +20,13 @@ pub fn editor_ui(
|
||||
.show(egui_context.get_mut(), |ui| {
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
ui.heading("Components Hierarchy");
|
||||
|
||||
bevy_inspector_egui::bevy_inspector::hierarchy::hierarchy_ui(
|
||||
world,
|
||||
ui,
|
||||
&mut selected_entities,
|
||||
);
|
||||
|
||||
println!("{:#?}", ui.clip_rect());
|
||||
ui.separator();
|
||||
|
||||
ui.heading("All Resources");
|
||||
bevy_inspector_egui::bevy_inspector::ui_for_resources(world, ui);
|
||||
ui.allocate_rect(ui.available_rect_before_wrap(), egui::Sense::hover());
|
||||
@ -41,7 +39,6 @@ pub fn editor_ui(
|
||||
.show(egui_context.get_mut(), |ui| {
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
ui.heading("Inspector");
|
||||
|
||||
match selected_entities.as_slice() {
|
||||
&[entity] => {
|
||||
bevy_inspector_egui::bevy_inspector::ui_for_entity(world, entity, ui);
|
||||
|
@ -2,7 +2,7 @@ use bevy::prelude::*;
|
||||
|
||||
use crate::{logic::core::{guns::{player_firing::PlayerFiringInfo, caliber::Caliber, firearm::Firearm, spray_pattern::FirearmSprayPattern}, player::{player_values_state::PlayerValuesState, camera_player_sync::MouseMovementSettings, player_movement::{PlayerLinearYState, PlayerLinearXZState, PlayerMovementInput}}}, comps::core::markers::{firearm::{FirearmData, MagazineData}, holdable::{HoldableObjectData, InPlayerHands}, player::{PlayerData, Player, PlayerHand}}, scenes::scene1::skybox::Cubemap, setup::{animations::{AllFirearmAnimations, FirearmAnimations}, assets::{GltfAssetType, GltfAssets}, equipment::Equipment, load_state::GameLoadState}};
|
||||
|
||||
use super::{panels::editor_ui, state::EditorUiState};
|
||||
use super::{panels::editor_ui, state::EditorUiState, camera::set_camera_viewport};
|
||||
|
||||
pub struct MainEditorUiPlugin;
|
||||
|
||||
@ -34,5 +34,6 @@ impl Plugin for MainEditorUiPlugin {
|
||||
.register_type::<GameLoadState>();
|
||||
app.insert_resource(EditorUiState::new());
|
||||
app.add_systems(Update, editor_ui);
|
||||
app.add_systems(PostUpdate, set_camera_viewport);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user