configured ui camera
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
use bevy::anti_alias::taa::TemporalAntiAliasing;
|
use bevy::anti_alias::taa::TemporalAntiAliasing;
|
||||||
|
use bevy::camera::visibility::RenderLayers;
|
||||||
use bevy::core_pipeline::prepass::DepthPrepass;
|
use bevy::core_pipeline::prepass::DepthPrepass;
|
||||||
use bevy::input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel};
|
use bevy::input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
@@ -53,8 +54,8 @@ fn setup(mut commands: Commands)
|
|||||||
PhosOrbitCamera::default(),
|
PhosOrbitCamera::default(),
|
||||||
TemporalAntiAliasing::default(),
|
TemporalAntiAliasing::default(),
|
||||||
))
|
))
|
||||||
.insert(Msaa::Off);
|
.insert(Msaa::Off)
|
||||||
// .insert(RenderLayers::layer(0))
|
.insert(RenderLayers::default());
|
||||||
|
|
||||||
// *msaa = Msaa::Off;
|
// *msaa = Msaa::Off;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
use bevy::{camera::visibility::RenderLayers, prelude::*};
|
use bevy::{
|
||||||
|
camera::{visibility::RenderLayers, CameraOutputMode, Viewport},
|
||||||
|
prelude::*,
|
||||||
|
render::render_resource::BlendState,
|
||||||
|
};
|
||||||
use shared::states::AssetLoadState;
|
use shared::states::AssetLoadState;
|
||||||
|
|
||||||
|
use crate::ui::states::BuildUIState;
|
||||||
pub struct BuildUIPlugin;
|
pub struct BuildUIPlugin;
|
||||||
|
|
||||||
impl Plugin for BuildUIPlugin
|
impl Plugin for BuildUIPlugin
|
||||||
@@ -7,33 +13,63 @@ impl Plugin for BuildUIPlugin
|
|||||||
fn build(&self, app: &mut App)
|
fn build(&self, app: &mut App)
|
||||||
{
|
{
|
||||||
app.add_systems(Startup, setup_cameras);
|
app.add_systems(Startup, setup_cameras);
|
||||||
app.add_systems(Update, spawn_ui.run_if(in_state(AssetLoadState::LoadComplete)));
|
app.insert_state(BuildUIState::Init);
|
||||||
|
app.add_systems(
|
||||||
|
Update,
|
||||||
|
spawn_ui.run_if(in_state(AssetLoadState::LoadComplete).and(in_state(BuildUIState::Init))),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_cameras(mut commands: Commands)
|
fn setup_cameras(mut commands: Commands)
|
||||||
{
|
{
|
||||||
commands.spawn((Camera2d, IsDefaultUiCamera, RenderLayers::layer(2)));
|
commands
|
||||||
|
.spawn((
|
||||||
|
Camera2d,
|
||||||
|
Camera {
|
||||||
|
order: 1,
|
||||||
|
clear_color: ClearColorConfig::None,
|
||||||
|
msaa_writeback: MsaaWriteback::Always,
|
||||||
|
// viewport: Some(Viewport {
|
||||||
|
// physical_size: UVec2::new(800, 800),
|
||||||
|
// ..default()
|
||||||
|
// }),
|
||||||
|
output_mode: CameraOutputMode::Write {
|
||||||
|
blend_state: Some(BlendState::ALPHA_BLENDING),
|
||||||
|
clear_color: ClearColorConfig::None,
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
IsDefaultUiCamera,
|
||||||
|
))
|
||||||
|
.insert(RenderLayers::layer(1))
|
||||||
|
.insert(Msaa::Off);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_ui(mut commands: Commands)
|
fn spawn_ui(mut commands: Commands, mut next_state: ResMut<NextState<BuildUIState>>)
|
||||||
{
|
{
|
||||||
commands
|
commands
|
||||||
.spawn((Node {
|
.spawn((
|
||||||
width: Val::Percent(100.),
|
Node {
|
||||||
height: Val::Percent(100.),
|
width: Val::Percent(100.),
|
||||||
justify_content: JustifyContent::Center,
|
height: Val::Percent(100.),
|
||||||
align_items: AlignItems::End,
|
justify_content: JustifyContent::Center,
|
||||||
..default()
|
align_items: AlignItems::End,
|
||||||
},))
|
..default()
|
||||||
|
},
|
||||||
|
RenderLayers::layer(1),
|
||||||
|
))
|
||||||
// .insert(PickingBehavior::IGNORE)
|
// .insert(PickingBehavior::IGNORE)
|
||||||
.with_children(|parent| {
|
.with_children(|parent| {
|
||||||
parent.spawn((
|
parent.spawn((
|
||||||
Node {
|
Node {
|
||||||
width: Val::Px(500.),
|
width: Val::Px(500.),
|
||||||
|
height: Val::Px(100.),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
BackgroundColor(LinearRgba::GREEN.into()),
|
BackgroundColor(LinearRgba::GREEN.into()),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
next_state.set(BuildUIState::Update);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
pub mod build_ui;
|
pub mod build_ui;
|
||||||
|
pub mod states;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum MenuState {
|
pub enum MenuState
|
||||||
|
{
|
||||||
Loading,
|
Loading,
|
||||||
Startup,
|
Startup,
|
||||||
MainMenu,
|
MainMenu,
|
||||||
@@ -10,14 +11,16 @@ pub enum MenuState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum GameplayState {
|
pub enum GameplayState
|
||||||
|
{
|
||||||
Waiting,
|
Waiting,
|
||||||
PlaceHQ,
|
PlaceHQ,
|
||||||
Playing,
|
Playing,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum AssetLoadState {
|
pub enum AssetLoadState
|
||||||
|
{
|
||||||
Loading,
|
Loading,
|
||||||
FinalizeAssets,
|
FinalizeAssets,
|
||||||
LoadComplete,
|
LoadComplete,
|
||||||
|
|||||||
Reference in New Issue
Block a user