Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion examples/app/headless_defaults.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
//! An application that runs with default plugins, but without an actual renderer.
//! This can be very useful for integration tests or CI.

use bevy::{prelude::*, render::settings::WgpuSettings};
use bevy::{app::AppExit, prelude::*, render::settings::WgpuSettings, window::WindowSettings};

fn main() {
App::new()
.insert_resource(WgpuSettings {
backends: None,
..default()
})
.insert_resource(WindowSettings {
add_primary_window: false,
exit_on_all_closed: false,
..default()
})
.add_plugins(DefaultPlugins)
.add_system(exit_unconditionally)
.run();
}

// Normally Bevy exits when all windows are closed.
//
// When running in headless mode there are no windows so
// you must manually send an [`bevy::app::AppExit`] event.
fn exit_unconditionally(mut app_exit_events: EventWriter<AppExit>) {
info!("Successfully ran! Exiting...");
app_exit_events.send(AppExit);
}