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_handlingset tofalsein theWindowPluginsettings) - Accesskit support
§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, EguiPrimaryContextPass};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(EguiPlugin::default())
.add_systems(Startup, setup_camera_system)
.add_systems(EguiPrimaryContextPass, ui_example_system)
.run();
}
fn setup_camera_system(mut commands: Commands) {
commands.spawn(Camera2d);
}
fn ui_example_system(mut contexts: EguiContexts) -> Result {
egui::Window::new("Hello").show(contexts.ctx_mut()?, |ui| {
ui.label("world");
});
Ok(())
}For more advanced examples, see the examples 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.
§absorb_input (live page, source: examples/absorb_input.rs)
Demonstrating the available options for absorbing input when Egui is using pointer or keyboard.
§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 a camera with a perspective projection to make rendering centered relative to the remaining screen area.
§split_screen (live page, source: examples/split_screen.rs)
Demonstrating how to render multiple Egui contexts, attaching them to several cameras that target the same window.
§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.
§run_manually (live page, source: examples/run_manually.rs)
The same minimal example demonstrating running Egui passes manually.
§See also
Re-exports§
pub use egui;
Modules§
- helpers
- Helpers for converting Bevy types into Egui ones and vice versa.
- input
- Systems for translating Bevy input messages into Egui input.
- node
- The names of
bevy_eguinodes. - output
- Systems for handling Egui output.
- picking
bevy_pickingintegration for Egui.- prelude
- Commonly-used items.
- render
- Rendering Egui with
bevy_render.
Structs§
- Egui
Clipboard - A resource for accessing clipboard.
- Egui
Context - A component for storing
bevy_eguicontext. - Egui
Context Settings - A component for storing Egui context settings.
- Egui
Contexts - A helper SystemParam that provides a way to get
EguiContextwith less boilerplate and combines a proxy interface to theEguiUserTexturesresource. - Egui
Full Output - Intermediate output buffer generated on an Egui pass end and consumed by the
process_output_systemsystem. - 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
EguiGlobalSettingsandEguiContextSettings. - 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
Pass Query - Egui
Pass Query Item - Automatically generated
WorldQueryitem type forEguiPassQuery, returned when iterating over query results. - Egui
Pass Query Read Only - Automatically generated
WorldQuerytype for a read-only variant ofEguiPassQuery. - Egui
Pass Query Read Only Item - Automatically generated
WorldQueryitem type forEguiPassQueryReadOnly, returned when iterating over query results. - Egui
Picking Order - Contains the order value that we add to
bevy_camera::Camera::orderforPointerHitsmessages. - Egui
Pixels PerPoint - Reflects the egui’s pixels per point value. The component lives only in the render world.
- Egui
Plugin - Adds all Egui resources and render graph nodes.
- Egui
Primary Context Pass - Use this schedule to run your UI systems with the primary Egui context.
- Egui
Render Output - Is used for storing Egui shapes and textures delta.
- Egui
Schedule - Add this component to your additional Egui contexts (e.g. when rendering to a new window or an image).
- Egui
User Textures - A resource for storing
bevy_eguiuser textures. - Egui
Zoom Factor - Reflects the egui’s zoom factor value. The component lives in the main world.
- Primary
Egui Context - A marker component for a primary Egui context. Users must add their systems to egui “aware” schedules. This requirement exists to support the egui multi-pass mode.
- Update
UiSize AndScale Query - Update
UiSize AndScale Query Item - Automatically generated
WorldQueryitem type forUpdateUiSizeAndScaleQuery, returned when iterating over query results. - Update
UiSize AndScale Query Read Only - Automatically generated
WorldQuerytype for a read-only variant ofUpdateUiSizeAndScaleQuery. - Update
UiSize AndScale Query Read Only Item - Automatically generated
WorldQueryitem type forUpdateUiSizeAndScaleQueryReadOnly, returned when iterating over query results.
Enums§
- Egui
Input Set - Subsets of the
EguiPreUpdateSet::ProcessInputset. - Egui
Post Update Set - System sets that run during the
PostUpdateschedule. - Egui
PreUpdate Set - System sets that run during the
PreUpdateschedule. - Egui
Startup Set - The
bevy_eguiplugin startup system sets. - Egui
Texture Handle - A wrapper type for an image handle or an asset id to mimic weak handles.
- UiRender
Order - Configures the rendering order between
eguiandbevy_ui_render(Bevy UI).
Traits§
- Bevy
Egui Entity Commands Ext - Extension for the
EntityCommandstrait.
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.
- run_
egui_ context_ pass_ loop_ system - Runs Egui contexts with the
EguiSchedulecomponent. If there are no contexts with this component, runs theEguiPrimaryContextPassschedule once independently. - setup_
primary_ egui_ context_ system - Adds bevy_egui components to a first found camera assuming it’s a primary one.
- update_
egui_ textures_ system - Updates textures painted by Egui.
- update_
ui_ screen_ rect - Updates UI
egui::RawInput::screen_rect.