Expand description
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 tofalse
in theWindowPlugin
settings)
§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:
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
§ui (live page, source: examples/ui.rs)
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
Re-exports§
pub use egui;
Modules§
- egui_
node - Egui render node.
- helpers
- Helpers for converting Bevy types into Egui ones and vice versa.
- input
- Systems for translating Bevy input events into Egui input.
- node
- The names of
bevy_egui
nodes. - output
- Systems for handling Egui output.
- render_
systems - Plugin systems for the render app.
Structs§
- Egui
Clipboard - A resource for accessing clipboard.
- Egui
Context - A component for storing
bevy_egui
context. - Egui
Context Settings - A component for storing Egui context settings.
- Egui
Contexts - A helper SystemParam that provides a way to get
EguiContext
with less boilerplate and combines a proxy interface to theEguiUserTextures
resource. - Egui
Full Output - Intermediate output buffer generated on an Egui pass end and consumed by the
process_output_system
system. - Egui
Global Settings - A resource for storing global plugin settings.
- Egui
Input - Is used for storing Egui context input.
- Egui
Input System Settings - All the systems are enabled by default. These settings exist within both
EguiGlobalSettings
andEguiContextSettings
. - Egui
Managed Texture - Represents a texture allocated and painted by Egui.
- Egui
Managed Textures - Contains textures allocated and painted by Egui.
- Egui
Output - Stores last Egui output.
- Egui
Plugin - Adds all Egui resources and render graph nodes.
- Egui
Render Output - Is used for storing Egui shapes and textures delta.
- Egui
Render ToImage - Contexts with this component will render UI to a specified image.
- Egui
User Textures - A resource for storing
bevy_egui
user textures. - Render
Target Size - Stores physical size and scale factor, is used as a helper to calculate logical size.
- Update
UiSize AndScale Query - Update
UiSize AndScale Query Item - Automatically generated
WorldQuery
item type forUpdateUiSizeAndScaleQuery
, returned when iterating over query results. - Update
UiSize AndScale Query Read Only - Automatically generated
WorldQuery
type for a read-only variant ofUpdateUiSizeAndScaleQuery
. - Update
UiSize AndScale Query Read Only Item - Automatically generated
WorldQuery
item type forUpdateUiSizeAndScaleQueryReadOnly
, returned when iterating over query results.
Enums§
- Egui
Input Set - Subsets of the
EguiPreUpdateSet::ProcessInput
set. - Egui
Post Update Set - System sets that run during the
PostUpdate
schedule. - Egui
PreUpdate Set - System sets that run during the
PreUpdate
schedule. - Egui
Startup Set - The
bevy_egui
plugin startup system sets.
Constants§
- PICKING_
ORDER - The ordering value used for
bevy_picking
.
Functions§
- begin_
pass_ system - Marks a pass start for Egui.
- capture_
pointer_ input_ system - Captures pointers on egui windows for
bevy_picking
. - end_
pass_ system - Marks a pass end for Egui.
- free_
egui_ textures_ system - This system is responsible for deleting image assets of freed Egui-managed textures and deleting Egui user textures of removed Bevy image assets.
- setup_
new_ windows_ system - Adds bevy_egui components to newly created windows.
- update_
egui_ textures_ system - Updates textures painted by Egui.
- update_
ui_ size_ and_ scale_ system - Updates UI
egui::RawInput::screen_rect
and callsegui::Context::set_pixels_per_point
.