Tainted\\Coders

Change the window title

Bevy version: 0.15Last updated:

The default window that Bevy spawns is created by the WindowPlugin.

When you add your DefaultPlugins you can customize the settings of each plugin with the DefaultPlugins::set method:

use bevy::prelude::*;

fn main() {
  let app_window = Some(Window {
    title: "Some title other than \"Bevy App\"".into(),
    ..default()
  });

  App::new()
    .add_plugins(DefaultPlugins.set(WindowPlugin {
      primary_window: app_window,
      ..default()
    }))
    // .. the rest of your app
    .run();
}

The Window component encapsulates all the settings related to how Bevy spawns your window across operating systems using the winit crate.

Typically in my projects I create a plugin specifically for the window with these settings:

use bevy::prelude::*;

const BACKGROUND_COLOR: Color = Color::srgb(0.4, 0.4, 0.4);

pub(super) fn plugin(app: &mut App) {
  let primary_window = Window {
    title: "Bevy game".into(),
    resizable: false,
    resolution: (800., 600.).into(),
    canvas: Some("#bevy".to_owned()),
    desired_maximum_frame_latency: core::num::NonZero::new(1u32),
    ..default()
  };

  app.insert_resource(ClearColor(BACKGROUND_COLOR))
    .add_plugins(DefaultPlugins.set(WindowPlugin {
      primary_window: Some(primary_window),
      ..default()
    }));
}

You can see more at my bevy-starter.