pub fn setup_new_windows_system(
    mut commands: Commands,
    new_windows: Query<(Entity, Option<&PrimaryWindow>), (Added<Window>, Without<EguiContext>)>,
    #[cfg(feature = "accesskit_placeholder")] adapters: Option<
        NonSend<bevy_winit::accessibility::AccessKitAdapters>,
    >,
    #[cfg(feature = "accesskit_placeholder")] mut manage_accessibility_updates: ResMut<
        bevy_a11y::ManageAccessibilityUpdates,
    >,
    enable_multipass_for_primary_context: Option<Res<EnableMultipassForPrimaryContext>>,
) {
    for (window, primary) in new_windows.iter() {
        let context = EguiContext::default();
        #[cfg(feature = "accesskit_placeholder")]
        if let Some(adapters) = &adapters {
            if adapters.get(&window).is_some() {
                context.ctx.enable_accesskit();
                **manage_accessibility_updates = false;
            }
        }
        // See the list of required components to check the full list of components we add.
        let mut window_commands = commands.entity(window);
        window_commands.insert(context);
        if enable_multipass_for_primary_context.is_some() && primary.is_some() {
            window_commands.insert(EguiMultipassSchedule::new(EguiContextPass));
        }
    }
}
Adds bevy_egui components to newly created windows.
src/lib.rs