/bevy_egui

A plugin for Egui integration into Bevy

Primary LanguageRustMIT LicenseMIT

bevy_egui

Crates.io Documentation License Downloads Rust

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

Trying out:

An example WASM project is live at mvlabat.github.io/bevy_egui_web_showcase [source].

Features:

bevy_egui can be compiled with using only bevy and egui as dependencies: manage_clipboard and open_url features, that require additional crates, can be disabled.

bevy_egui

Dependencies

On Linux, this crate requires certain parts of XCB are installed on your system. On Debian-based systems, these can be installed with the 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.5"
bevy_egui = "0.7"
use bevy::prelude::*;
use bevy_egui::{egui, EguiContext, EguiPlugin};

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_plugin(EguiPlugin)
        .add_system(ui_example.system())
        .run();
}

// Note the usage of `ResMut`. Even though `ctx` method doesn't require
// mutability, accessing the context from different threads will result
// into panic if you don't enable `egui/multi_threaded` feature.
fn ui_example(egui_context: ResMut<EguiContext>) {
    egui::Window::new("Hello").show(egui_context.ctx(), |ui| {
        ui.label("world");
    });
}

For a more advanced example, see examples/ui.rs.

cargo run --example ui

See also

Bevy support table

bevy bevy_egui
0.5 0.4-0.7
0.4 0.1-0.3