Skip to content

This crate provides an Egui integration for the Bevy game engine.

License

Notifications You must be signed in to change notification settings

gehud/bevy_egui

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bevy_egui

Crates.io Documentation License Downloads Rust

This crate provides an Egui integration for the Bevy game engine.

Trying out:

A basic WASM example is live at vladbat00.github.io/bevy_egui/ui.

Features:

  • Desktop and web platforms support
  • Clipboard
  • Opening URLs
  • Multiple windows support (see ./examples/two_windows.rs)
  • Paint callback support (see ./examples/paint_callback.rs)
  • Mobile web virtual keyboard (still rough around the edges and only works without prevent_default_event_handling set to false in the WindowPlugin settings)

bevy_egui

Dependencies

On Linux, this crate requires certain parts of XCB to be installed on your system. On Debian-based systems, these can be installed with the following command:

sudo apt install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev

Usage

Here's a minimal usage example:

# Cargo.toml
[dependencies]
bevy = "0.15"
bevy_egui = "0.32"
use bevy::prelude::*;
use bevy_egui::{egui, EguiContexts, EguiPlugin};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(EguiPlugin)
        // Systems that create Egui widgets should be run during the `Update` Bevy schedule,
        // or after the `EguiPreUpdateSet::BeginPass` system (which belongs to the `PreUpdate` Bevy schedule).
        .add_systems(Update, ui_example_system)
        .run();
}

fn ui_example_system(mut contexts: EguiContexts) {
    egui::Window::new("Hello").show(contexts.ctx_mut(), |ui| {
        ui.label("world");
    });
}

For more advanced examples, see the section below.

Examples

To run an example, use the following command (you may replace ui with a name of another example):

cargo run --example ui

Showcasing some more advanced UI, rendering images, hidpi scaling.

color_test (live page, source: examples/color_test.rs)

Rendering test from egui.rs. We don't fully pass it, help is wanted (#291).

side_panel (live page, source: examples/side_panel.rs)

Showing how to display an Egui side panel and transform camera to make rendering centered relative to the remaining screen area.

render_egui_to_image (live page, source: examples/render_egui_to_image.rs)

Rendering UI to an image (texture) and then using it as a mesh material texture.

render_to_image_widget (live page, source: examples/render_to_image_widget.rs)

Rendering to a texture with Bevy and showing it as an Egui image widget.

two_windows (source: examples/two_windows.rs)

Setting up two windows with an Egui context for each.

paint_callback (live page, source: examples/paint_callback.rs)

Using Egui paint callbacks.

simple (live page, source: examples/simple.rs)

The minimal usage example from this readme.

simple_multipass (live page, source: examples/simple_multipass.rs)

The same minimal example demonstrating running Egui passes manually.

See also

Bevy support table

Note: if you're looking for a bevy_egui version that supports main branch of Bevy, check out open PRs, there's a great chance we've already started working on the future Bevy release support.

bevy bevy_egui
0.15 0.31-0.32
0.14 0.28-0.30
0.13 0.25-0.27
0.12 0.23-0.24
0.11 0.21-0.22
0.10 0.20
0.9 0.17-0.19
0.8 0.15-0.16
0.7 0.13-0.14
0.6 0.10-0.12
0.5 0.4-0.9
0.4 0.1-0.3

About

This crate provides an Egui integration for the Bevy game engine.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 99.2%
  • WGSL 0.8%