I can haz UI?
This commit is contained in:
@@ -5,8 +5,6 @@ use bevy::app::ScheduleRunnerPlugin;
|
||||
use bevy::camera::RenderTarget;
|
||||
use bevy::color::Color;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::RenderPlugin;
|
||||
use bevy::winit::WinitPlugin;
|
||||
use wgpu::{TextureFormat, TextureUsages};
|
||||
|
||||
mod post_process;
|
||||
@@ -21,19 +19,21 @@ mod shared;
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins((
|
||||
DefaultPlugins
|
||||
.set(RenderPlugin {
|
||||
synchronous_pipeline_compilation: true,
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
resolution: bevy::window::WindowResolution::new(160 * 4, 43 * 4)
|
||||
.with_scale_factor_override(4.0),
|
||||
..default()
|
||||
})
|
||||
.build()
|
||||
.disable::<WinitPlugin>(),
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1. / 30.)),
|
||||
post_process::PostProcessPlugin,
|
||||
ImageExportPlugin,
|
||||
))
|
||||
.insert_resource(ClearColor(Color::linear_rgba(0.0, 0.0, 0.0, 1.0)))
|
||||
.insert_resource(ClearColor(Color::linear_rgba(0.0, 0.0, 0.0, 0.0)))
|
||||
.add_systems(Startup, setup_scene_system)
|
||||
.add_systems(PostStartup, spawn_in_ui)
|
||||
.add_systems(Update, rotate_cube)
|
||||
.run();
|
||||
}
|
||||
@@ -66,18 +66,44 @@ fn setup_scene_system(
|
||||
Camera::default(),
|
||||
RenderTarget::Image(image_handle.clone().into()),
|
||||
Transform::from_xyz(0.0, 1.0, 2.5).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
UiAntiAlias::Off,
|
||||
PostProcessSettings { scale: 1.0 },
|
||||
));
|
||||
|
||||
commands.spawn((ImageExport(export_sources.add(image_handle)),));
|
||||
}
|
||||
|
||||
fn spawn_in_ui(mut commands: Commands, assets: Res<AssetServer>, camera: Query<(Entity, &Camera)>) {
|
||||
let font: Handle<Font> = assets.load("fonts/Roboto-Bold.ttf");
|
||||
|
||||
let text_font = TextFont::from(font.clone())
|
||||
.with_font_size(12.)
|
||||
.with_font_smoothing(bevy::text::FontSmoothing::None);
|
||||
|
||||
let Ok(main_camera) = camera.single() else {
|
||||
return; // no camera... yet?
|
||||
};
|
||||
|
||||
commands.spawn((
|
||||
Node {
|
||||
position_type: PositionType::Absolute,
|
||||
top: Val::Px(5.0),
|
||||
left: Val::Px(5.0),
|
||||
..default()
|
||||
},
|
||||
Text::new("Hello World!"),
|
||||
text_font.clone(),
|
||||
TextColor(Color::WHITE),
|
||||
UiTargetCamera(main_camera.0),
|
||||
));
|
||||
}
|
||||
|
||||
fn rotate_cube(
|
||||
mut cubes: Query<(&mut Transform, &Spinner)>,
|
||||
timer: Res<Time>,
|
||||
g13: Res<G13Resource>,
|
||||
) {
|
||||
const DEADZONE: i32 = 30;
|
||||
const DEADZONE: i32 = 35;
|
||||
|
||||
let g13 = g13.g13.state();
|
||||
let mut x = g13.x as f32 / 512.0;
|
||||
|
||||
Reference in New Issue
Block a user