latest version

ggez_egui

An egui implementation for the ggez game framework

First steps

To make use of this implementation you must first add the "EguiBackend" inside your game structure and initialize it. Ej: rust struct MyGame { egui_backend: EguiBackend, ... } ... let game = MyGame { egui_backend: EguiBackend::default(), //or EguiBackend::new(ctx) ... }

later, in the part of the "EventHandler", inside the "update" we will add the structure and logic of the ui, inside the "draw" we will send to draw the ui, and at the end we will detect the user input. Ej: ```rust impl EventHandler for MyGame { fn update(&mut self, ctx: &mut Context) -> GameResult { let eguictx = self.eguibackend.ctx(); egui::Window::new("egui-window").show(&eguictx, |ui| { ui.label("a very nice gui :3"); if ui.button("print \"hello world\"").clicked() { println!("hello world"); } if ui.button("quit").clicked() { quit(ctx); } }); self.eguibackend.update(ctx); // Update the input with the data from the context with exceptions (scalefactor, resize, mousewheel, and text_input) Ok(()) }

fn draw(&mut self, ctx: &mut Context) -> GameResult {
    clear(ctx, Color::BLACK);
    draw(ctx, &self.egui_backend, ([0.0, 0.0],))?;
    present(ctx)
}

} ``` In this case we only handle the mouse input so we only use those three functions (mousebuttondownevent, mousebuttonupevent, mousemotionevent), it is not very necessary to explain them because their names are already very descriptive. If we need to manage other things in the window such as the keyboard, the size, or even the scale factor, there are also respective functions for that, check out the Input Documentation.

there are a few examples to know how to use this implementation.