Skip to content

Make headless_defaults example actually headless #5261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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);
}