Tried to use egui::dock but ended up just using a manual egui
This commit is contained in:
parent
83bc4f1073
commit
2683d75462
|
@ -1,9 +1,9 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
use bevy_inspector_egui::{DefaultInspectorConfigPlugin, bevy_egui::{self}};
|
||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
use logic::core::{guns::player_firing::PlayerFiringInfo, player::player_values_state::PlayerValuesState};
|
use logic::core::{guns::player_firing::PlayerFiringInfo, player::player_values_state::PlayerValuesState};
|
||||||
use scenes::scene1;
|
use scenes::scene1;
|
||||||
use ui::game::plugin::MainGameUIPlugin;
|
use ui::{game::plugin::MainGameUIPlugin, editor::plugin::MainEditorUiPlugin};
|
||||||
|
|
||||||
mod comps;
|
mod comps;
|
||||||
mod constants;
|
mod constants;
|
||||||
|
@ -26,9 +26,12 @@ fn main() {
|
||||||
fn setup_plugins(application: &mut App) {
|
fn setup_plugins(application: &mut App) {
|
||||||
application
|
application
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
.add_plugins(DefaultInspectorConfigPlugin)
|
||||||
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default())
|
.add_plugins(RapierPhysicsPlugin::<NoUserData>::default())
|
||||||
.add_plugins(WorldInspectorPlugin::new())
|
.add_plugins(bevy_egui::EguiPlugin)
|
||||||
|
//.add_plugins(WorldInspectorPlugin::new())
|
||||||
.add_plugins(MainGameUIPlugin)
|
.add_plugins(MainGameUIPlugin)
|
||||||
|
.add_plugins(MainEditorUiPlugin)
|
||||||
.register_type::<PlayerFiringInfo>()
|
.register_type::<PlayerFiringInfo>()
|
||||||
.register_type::<PlayerValuesState>();
|
.register_type::<PlayerValuesState>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
//! Editor UI means everything that won't be in the actual game
|
//! Editor UI means everything that won't be in the actual game
|
||||||
pub mod plugin;
|
pub mod plugin;
|
||||||
|
pub mod panels;
|
||||||
|
pub mod state;
|
|
@ -0,0 +1,58 @@
|
||||||
|
use bevy::{prelude::*, window::PrimaryWindow};
|
||||||
|
use bevy_inspector_egui::{bevy_inspector::hierarchy::SelectedEntities, bevy_egui::EguiContext, egui};
|
||||||
|
|
||||||
|
use crate::ui::game::settings::SettingsScreenUIConfiguration;
|
||||||
|
|
||||||
|
pub fn editor_ui(
|
||||||
|
world: &mut World,
|
||||||
|
mut selected_entities: Local<SelectedEntities>,
|
||||||
|
) {
|
||||||
|
if !world.resource::<SettingsScreenUIConfiguration>().settings_menu_shown {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let mut egui_context = world
|
||||||
|
.query_filtered::<&mut EguiContext, With<PrimaryWindow>>()
|
||||||
|
.single(world)
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
egui::SidePanel::left("hierarchy")
|
||||||
|
.default_width(250.0)
|
||||||
|
.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,
|
||||||
|
);
|
||||||
|
|
||||||
|
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());
|
||||||
|
ui.allocate_space(ui.available_size());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
egui::SidePanel::right("inspector")
|
||||||
|
.default_width(250.0)
|
||||||
|
.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);
|
||||||
|
}
|
||||||
|
entities => {
|
||||||
|
bevy_inspector_egui::bevy_inspector::ui_for_entities_shared_components(
|
||||||
|
world, entities, ui,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.allocate_space(ui.available_size());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
pub struct MainEditorUIPlugin;
|
use super::{panels::editor_ui, state::EditorUiState};
|
||||||
|
|
||||||
#[allow(unused)]
|
pub struct MainEditorUiPlugin;
|
||||||
impl Plugin for MainEditorUIPlugin {
|
|
||||||
|
impl Plugin for MainEditorUiPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
todo!()
|
app.insert_resource(EditorUiState::new());
|
||||||
|
app.add_systems(Update, editor_ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
use bevy::prelude::*;
|
||||||
|
use bevy_inspector_egui::egui;
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
pub struct EditorUiState {
|
||||||
|
pub viewport_rect: egui::Rect,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EditorUiState {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
viewport_rect: egui::Rect::NOTHING,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue