pub fn setup_new_egui_nodes_system(
    windows: Extract<
        Query<(Entity, &RenderEntity, AnyOf<(&Window, &EguiRenderToImage)>), Added<EguiContext>>,
    >,
    mut render_graph: ResMut<RenderGraph>,
) {
    for (main_entity, render_entity, (window, render_to_image)) in windows.iter() {
        let egui_pass = EguiPass::from_window_entity(main_entity);
        let new_node = EguiNode::new(
            MainEntity::from(main_entity),
            *render_entity,
            match (window.is_some(), render_to_image.is_some()) {
                (true, false) => EguiRenderTargetType::Window,
                (false, true) => EguiRenderTargetType::Image,
                (true, true) => {
                    log::error!(
                        "Failed to set up an Egui node: can't render both to a window and an image"
                    );
                    continue;
                }
                (false, false) => unreachable!(),
            },
        );

        render_graph.add_node(egui_pass.clone(), new_node);

        render_graph.add_node_edge(bevy_render::graph::CameraDriverLabel, egui_pass);
    }
}
Sets up render nodes for newly created Egui contexts.
src/render_systems.rs