Git Product home page Git Product logo

bevy_egui's Introduction

Stand With Ukraine

Hey! I'm the author of the crate, and I was born in Mariupol, Ukraine. When russians started the war in 2014, I moved to Kyiv. My parents, who had been staying in Mariupol till the start of the full-scale invasion, barely escaped the city alive. By the moment of writing (November 5th, 2023), we had 874 air raid alerts in Kyiv, and russians managed to bomb the city 132 times.

If you are using this crate, please consider donating to any of the listed funds (see the banner above), that will mean a lot to me.

bevy_egui

Crates.io Documentation License Downloads Rust

This crate provides an 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, egui and bytemuck 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 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.14"
bevy_egui = "0.28"
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 `CoreSet::Update` set,
        // or after the `EguiSet::BeginFrame` system (which belongs to the `CoreSet::PreUpdate` set).
        .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 a more advanced example, see examples/ui.rs.

cargo run --example ui

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.14 0.28
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

bevy_egui's People

Contributors

aevyrie avatar andriydev avatar connerebbinghaus avatar dependabot[bot] avatar dimvoly avatar emilk avatar frewsxcv avatar galop1n avatar jakobhellermann avatar lain-dono avatar lukors avatar maximetinu avatar meshiest avatar mvlabat avatar ndarilek avatar paul-hansen avatar raffaeleragni avatar rdelfin avatar shatur avatar sludgephd avatar swoorup avatar thebutlah avatar therawmeatball avatar tomuxmon avatar vihdzp avatar vrixyz avatar weasy666 avatar willcrichton avatar zachbateman avatar zicklag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bevy_egui's Issues

[Bug] Image sampling artifacts when not rendering in physical pixels

How to reproduce:

  • run the supplied ui example
  • toggle scale with the / key

1:1 physical pixel scale:
image

Default DPI-aware scaling:
image

This issue is specifically for the aliasing seen in the middle of the image, e.g. the bird's chest. There is a different alpha bug that causes aliasing at the border of the circle that applies to any image with transparency.

remove dependency of winit / bevy_winit

I'm trying to use a glfw backend for bevy instead of the default bevy_winit backend. I wanted to use bevy_egui and bevy_inspector_egui, but bevy_egui explicitly depends on winit. I was hoping to feature-gate those code parts or make them generic traits so that bevy_egui can be more.. portable (?).

places where winit specific code is used:

  1. a couple workarounds for scroll delta https://github.com/mvlabat/bevy_egui/blob/main/src/systems.rs#L198
  2. setting cursoricon which is gated behind clipboard feature https://github.com/mvlabat/bevy_egui/blob/main/src/systems.rs#L365

I think they are that important to keep bevy_egui specific to only winit backend.

Wayland support

Both bevy and winit support wayland surfaces natively, but bevy_egui opts out of the necessary feature flags.

In testing, it looks like just enabling them works fine. I don't know how to test if it makes a difference on wasm, though. Consider enabling wayland for bevy and winit, or at least supporting this through a feature flag?

Crash when minimising the "Window" widget

Hi,

When I run the ui.rs example and I "minimize" the "Window" widget I consistently get the following crash ( https://github.com/mvlabat/bevy_egui/blob/main/examples/ui.rs#L110):

wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(1, 284, Metal)>`
    In a set_scissor_rect command
    Invalid ScissorRect parameters


thread 'main' panicked at 'Handling wgpu errors as fatal by default', /.../.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.7.1/src/backend/direct.rs:1896:5
stack backtrace:
  11: <bevy_egui::egui_node::EguiNode as bevy_render::render_graph::node::Node>::update
             at ./src/egui_node.rs:266:9
          at ./examples/ui.rs:7:5

Weird touch behavior on mobile device

I found problems on mobile device and chrome developer tool's mobile device mode. The video is recorded on chrome on macbook.
This happpens in https://desk-x.com and your demo mvlabat.github.io/bevy_egui_web_showcase, and does not happens in https://egui.rs

Problems

  1. Drag position is reset on any next touch.
  2. It can be moved by dragging any position.

Possible solution

Proper handling of touch release event (or something).

Screen.Recording.0004-05-07.at.8.29.25.mov

Provide Description on How to Adjust Scene Render Window

I currently have an app with an egui::SidePanel on the left and an egui::TopBottomPanel on the bottom. This is working great. Now if I go to Bevy and add an obj file and render it, I can see that the panels are simply drawn on top of the scene rendering context. What I would like is for the the rendering scene to fill the space that is not covered by the panels. So, shifted to the upper right area of the window, in this way, the world point (0, 0, 0) would be at the center of the un-paneled space. (does this make sense)

I am not sure how to make this adjustment, I have been going though the Bevy docs but did not see anything there. Thought it might be in one of the bevy_egui examples but it does not seem so.

Can this be done? If so, can you add some documentation to point peeps in the right direction? :).

Runtime Error on examples as Main Windows10

I cloned the crate and I can run the examples from the command line fine. ex cargo run --example simple

If I make a main.rs and fill it with the contents of simple.rs and cargo run it will fail with a runtime error and a gnarly error

thread 'thread 'thread 'mainCompute Task Pool (5)Compute Task Pool (2)' panicked at '' panicked at '' panicked at 'Requested resource does not exist: alloc::boxed::Box<dyn bevy_render::renderer::render_resource_context::RenderResourceContext>Requested resource does not exist: alloc::boxed::Box<dyn bevy_render::renderer::render_resource_context::RenderResourceContext>Requested resource does not exist: alloc::boxed::Box<dyn bevy_render::renderer::render_resource_context::RenderResourceContext>', ', ', C:\Users\jmw99\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\system\system_param.rsC:\Users\jmw99\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\system\system_param.rsC:\Users\jmw99\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.5.0\src\system\system_param.rs:::244244244:::171717

and it's full backtrace simple backtrace.txt

I am using windows 10, is there any special configuration I have to do in the TOML? It clearly can work as it runs from the example configurations no problem. Thanks

Can a `Res<EguiContext>` be used in two parallel systems?

This is more of a question than an issue. In my application, I currently have various parallel systems showing different windows. Most times they work just fine, but they occasionally provoke a startup crash, so I wonder if this is a limitation or a bug.

The first few lines of the startup crash error message:

thread 'main' panicked at 'already mutably borrowed', C:\Users\vi\.cargo\registry\src\github.com-1ecc6299db9ec823\atomic_refcell-0.1.7\src\lib.rs:151:23
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53\/library\std\src\panicking.rs:493
   1: core::panicking::panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53\/library\core\src\panicking.rs:92
   2: core::panicking::panic_str
             at C:\Users\vi\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\panicking.rs:57
   3: atomic_refcell::AtomicRefCell<egui::memory::Memory>::borrow_mut<egui::memory::Memory>
             at C:\Users\vi\.cargo\registry\src\github.com-1ecc6299db9ec823\atomic_refcell-0.1.7\src\lib.rs:151
   4: epaint::mutex::Mutex<egui::memory::Memory>::lock
             at C:\Users\vi\.cargo\git\checkouts\egui-5e4507fa4153be06\effd3c7\epaint\src\mutex.rs:144
   5: egui::context::Context::memory
             at C:\Users\vi\.cargo\git\checkouts\egui-5e4507fa4153be06\effd3c7\egui\src\context.rs:378
   6: egui::context::Context::style
             at C:\Users\vi\.cargo\git\checkouts\egui-5e4507fa4153be06\effd3c7\egui\src\context.rs:443
   7: egui::containers::window::{{impl}}::show_impl::{{closure}}
             at C:\Users\vi\.cargo\git\checkouts\egui-5e4507fa4153be06\effd3c7\egui\src\containers\window.rs:255
   8: core::option::Option<egui::containers::frame::Frame>::unwrap_or_else<egui::containers::frame::Frame,closure-0>
             at C:\Users\vi\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\option.rs:427
   9: egui::containers::window::Window::show_impl
             at C:\Users\vi\.cargo\git\checkouts\egui-5e4507fa4153be06\effd3c7\egui\src\containers\window.rs:255
  10: egui::containers::window::Window::show<closure-0>
             at C:\Users\vi\.cargo\git\checkouts\egui-5e4507fa4153be06\effd3c7\egui\src\containers\window.rs:236

Egui crashes with "no entry found for key"

Today I tried updating both bevy and bevy_egui to their latest versions. Suddenly, in my UI system, I can no longer get the context for the primary window. The code looks like this:

pub fn ui(
    egui_ctx: ResMut<EguiContext>,
    // other stuff...
) {
    let ctx = egui_ctx.ctx(); // crashes
    
    // other stuff...
}

Oddly enough the example code seems to work just fine. I have no idea which interactions within the code might be causing the crash. I can upload the full code if it helps.

Example for a panel side-by-side with bevy main camera

I would like to build an editor-style application with an egui-rendered panel next to a view of my in-game world. Right now, the closest example I could find to that is two_windows.rs which spawns a window on top of a bevy camera. I don't really want to use a window, I just a panel docked to one (ideally, both) sides of the screen with a bevy camera drawing the middle.

Is this even possible with egui? Do I need to install a Frame, maybe? If you can point me towards the right solution - and if I get it working - I'll contribute back an example.

Holding arrow keys in text panel does not keep moving cursor.

Summary

Holding an arrow key, both in the ui example, and in my project, does not keep moving the cursor inside ui.text_edit_singleline elements.

In the official egui demo app this works.

How to Reproduce

  • cargo run --example ui
  • Click the "Write something" panel on the left; hold a, observe production of aaaaaaaaaaaaaaaaa
  • While still in panel, hold Arrow left. The cursor will only jump one character left.

how to change the logo color

Hello, i see how to load and remove the bevy logo picture.
What i'd like to do is to send signal to change the logo teint / color , but keep the texture.

The dirty solution is to have many png similar but with preprocessed colors and to load it when needed.

The wished solution would be to have buttons to increment/decrement RGBA canals, and to get fast changing colors on the left side panel. Is there a struct field or method to target the color inside egui part ?
The bevy part is SpriteBundle.sprite.color

What i thought is to access through a Component like this:

#[derive(Component)]
struct CurrentColorIndicator;

but here :

egui::SidePanel::left("side_panel")
        .default_width(100.0)
        .show(egui_ctx.ctx(), |ui| {
            ui.heading("Side Panel");            

            ui.add(egui::widgets::Image::new(
                egui::TextureId::User(BEVY_TEXTURE_ID),
                [256.0, 256.0],
            ));
        .insert(CurrentColorIndicator)

i can not do
.insert(CurrentColorIndicator)

Keys now trigger actions on hold, not press

Hey, not sure if this is on bevy_egui's end or if I'll have to chase it through egui. I updated https://github.com/ndarilek/bevy_egui_a11y to work on Bevy 0.6. Formerly, pressing tab moved focus once. Now it seems to move focus rapidly.

It seems like some of these events are being triggered on hold rather than just on press. Focus should only move once when I press tab.

Thanks!

bevy_egui race condition with bevy_ui

When mixing bevy_ui and bevy_egui in a project, it's random which one will be rendered on top of the other.

Pic about egui being rendered below bevy ui (in this case there is a blueish background covering the whole screen):
image
How it should look like:
unknown

It's random whether egui will be above bevyui for each start.

Discord discussion about the issue in the Bevy Discord: https://discord.com/channels/691052431525675048/929761837363363950/929762436733624410

Dependencies:
bevy = "0.6.0"
bevy_egui = "0.10.0"

Support drawing images from TextureAtlases

set_egui_texture only supports rendering Textures. It'd be great if I could draw a subsection of a TextureAtlas. Maybe by calling something like:

set_egui_texture_atlas(id: u64, texture_atlas: Handle<TextureAtlas>, texture_index: u32)

The specific use case I'm trying to support is previewing animated sprites in egui.

By the way, bevy_egui has been amazing to use so far! Thanks so much for making it :)

Checking if keyboard/mouse event was/should be handled by egui

Is there a way to check if egui is handling the currently received input event? I'm trying to add hotkeys but need to know first if the UI should be handling the event or if I should handle it in the game. I think I could basically check if any text input has focus, but it seems like there should be a better way

Bevy render to texture

Please excuse this non-issue, just looking for some help.
I'm looking to render a 3D scene with bevy and show it in a egui window as an image, the bevy_gui example is very close to what I want. I was wondering if you had any pointers or examples of how to render to a texture instead of the screen in bevy.

Compiler error in bevy 0.6

7 | .add_plugin(EguiPlugin)
| ---------- ^^^^^^^^^^ the trait bevy::prelude::Plugin is not implemented for EguiPlugin
| |
| required by a bound introduced by this call

gfx_backend_vulkan error

I have just added env_logger::init(); to the simple.rs example and I'm getting the following message every frame:

[2021-10-04T09:17:50Z ERROR gfx_backend_vulkan]
    VALIDATION [UNASSIGNED-CoreValidation-DrawState-QueueForwardProgress (-400166253)] : Validation Error: [ UNASSIGNED-CoreValidation-DrawState-QueueForwardProgress ] Object 0: handle = 0xea7170000000031, type = VK_OBJECT_TYPE_SEMAPHORE; Object 1: handle = 0x1e5f980a668, type = VK_OBJECT_TYPE_QUEUE; Object 2: handle = 0x1e5f980a668, type = VK_OBJECT_TYPE_QUEUE; | MessageID = 0xe825f293 | vkQueueSubmit(): pSubmits[0].pSignalSemaphores[0] is signaling VkQueue 0x1e5f980a668[] (VkSemaphore 0xea7170000000031[]) that was previously signaled by VkQueue 0x1e5f980a668[] but has not since been waited on by any queue.
    object info: (type: SEMAPHORE, hndl: 1055837926409109553), (type: QUEUE, hndl: 2087245096552), (type: QUEUE, hndl: 2087245096552)

Here's my setup.
Dependencies:

bevy = "0.5.0"
bevy_egui = "0.7.0"
env_logger = "0.9.0"

compiler: rustc 1.57.0-nightly (9dbb26efe 2021-10-03)
OS: Windows 10
GPU: GeForce GTX 1050 Ti
GPU driver: NVIDIA 472.12

Let me know if I can provide any further information to help reproduce.

Provide ability to use GIT egui

I have a situation where I would like to use a Table widget. This is not built into the released version of egui right now, but seems as though a recent merge to master has provided some basic functionality. Is there a way (without forking bevy_egui) that I can get bevy_egui to use the GIT version of egui? Right now it seems as though it is hard coded.

See discussion at emilk/egui#296 and emilk/egui#963 for more details.

Possibly adding a feature flag for a specific git branch of egui would be nice.

UI not rendering

I recently updated bevy_egui to 0.12.1 (from 0.11) and bevy-inspector-egui to 0.9 (from 0.8). Both are now using egui 0.17, as checked via cargo tree.

Code that previously rendered fine does nothing. It runs (evidenced by debugging print statements inside a Window::new("").show() function. All the bevy systems are still running, but the egui code yields nothing.

There are no errors in compilation, no panics.

Perhaps an issue with providing the right contexts/data for bevy and egui in #78 ?

Absorbing/suppressing keyboard/mouse input when hovering over egui window

Hey

I'm having issues (and generally a nice time!) with using bevy-egui, and mouse/keyboard input still being consumed by the main bevy system code. This would be something nice to suppress somehow, probably opt-in, however I do feel that generally the happy path is for egui related input to be handled by egui, then suppressed (if possible).

Currently I am suppressing if egui.has_pointer_focus() (or somesuch), however, all my input processing code on the bevy side has to be made aware of egui, and it is getting unweildy.

I don't have enough of an understanding of bevy's input system, and where bevy-egui actually get's it's input from, to know where this is solvable from, so I'm just asking here as it seems the most obvious choice.

Is this solvable within bevy-egui? Is it currently do-able with bevy's input system?

Thanks

Can't build without the clipboard feature

First of all, thanks for bringing egui to bevy !

It seems that the manage_clipboard isn't considered in several places. I tried:

cargo run --example simple --no-default-features --features="bevy/x11 bevy/bevy_wgpu"

And got a bunch of errors:

error[E0432]: unresolved import `crate::EguiClipboard`
 --> src/systems.rs:2:5
  |
2 |     EguiClipboard, EguiContext, EguiInput, EguiOutput, EguiSettings, EguiShapes, WindowSize,
  |     ^^^^^^^^^^^^^ no `EguiClipboard` in the root

error[E0433]: failed to resolve: use of undeclared type `ClipboardContext`
   --> src/lib.rs:185:17
    |
185 |                 ClipboardContext::new()
    |                 ^^^^^^^^^^^^^^^^ use of undeclared type `ClipboardContext`

error[E0433]: failed to resolve: use of undeclared type `RefCell`
   --> src/lib.rs:186:26
    |
186 |                     .map(RefCell::new)
    |                          ^^^^^^^ use of undeclared type `RefCell`

error[E0433]: failed to resolve: use of undeclared type `EguiClipboard`
   --> src/lib.rs:349:38
    |
349 |         resources.get_or_insert_with(EguiClipboard::default);
    |                                      ^^^^^^^^^^^^^ use of undeclared type `EguiClipboard`

error[E0412]: cannot find type `EguiClipboard` in this scope
   --> src/lib.rs:140:6
    |
140 | impl EguiClipboard {
    |      ^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `RefMut` in this scope
   --> src/lib.rs:182:29
    |
182 |     fn get(&self) -> Option<RefMut<ClipboardContext>> {
    |                             ^^^^^^ not found in this scope
    |
help: consider importing one of these items
    |
49  | use bevy::ecs::RefMut;
    |
49  | use core::cell::RefMut;
    |
49  | use std::cell::RefMut;
    |

error[E0412]: cannot find type `ClipboardContext` in this scope
   --> src/lib.rs:182:36
    |
140 | impl EguiClipboard {
    |     - help: you might be missing a type parameter: `<ClipboardContext>`
...
182 |     fn get(&self) -> Option<RefMut<ClipboardContext>> {
    |                                    ^^^^^^^^^^^^^^^^ not found in this scope

warning: unused import: `log`
  --> src/systems.rs:13:5
   |
13 |     log,
   |     ^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error[E0599]: no method named `system` found for fn item `for<'r, 's, 't0, 't1, 't2, 't3> fn(Res<'r, EguiContext>, ResMut<'s, EguiOutput>, ResMut<'t0, EguiShapes>, ResMut<'t1, [type error]>, Res<'t2, bevy::prelude::Windows>, Res<'t3, WinitWindows>) {systems::process_output}` in the current scope
   --> src/lib.rs:342:69
    |
342 |         app.add_system_to_stage(stage::UI_FRAME_END, process_output.system());
    |                                                                     ^^^^^^ method not found in `for<'r, 's, 't0, 't1, 't2, 't3> fn(Res<'r, EguiContext>, ResMut<'s, EguiOutput>, ResMut<'t0, EguiShapes>, ResMut<'t1, [type error]>, Res<'t2, bevy::prelude::Windows>, Res<'t3, WinitWindows>) {systems::process_output}`
    |
    = note: `process_output` is a function, perhaps you wish to call it

error: aborting due to 8 previous errors; 1 warning emitted

Consuming input events

This isn't really an issue, more of a question... I was wondering, it is possible to check if any GUI elements from egui consumed an input event? Basically, I want to avoid getting input events in my own entities if the user e.g. clicked on a gui element, so I don't get the mouse events twice. (e.g. in a FPS game if you click the "pause" button, it shouldn't shoot the gun, because the GUI should've already consumed the input event)

Bevy 0.7.0-dev support

I did not see a PR for this.

Build against current bevy git (https://github.com/bevyengine/bevy#449a1d223c170cf22b4034217774c47bcaf93482) fails with the following errors:

error[E0432]: unresolved import `bevy::app::EventReader`
 --> src/systems.rs:7:5
  |
7 |     app::EventReader,
  |     ^^^^^^^^^^^^^^^^ no `EventReader` in `app`

error[E0277]: `*const ()` cannot be sent between threads safely
   --> src/systems.rs:344:27
    |
344 |     winit_windows: Option<Res<WinitWindows>>,
    |                           ^^^^^^^^^^^^^^^^^ `*const ()` cannot be sent between threads safely
    |
    = help: within `WinitWindows`, the trait `Send` is not implemented for `*const ()`
    = note: required because it appears within the type `PhantomData<*const ()>`
    = note: required because it appears within the type `WinitWindows`
    = note: required because of the requirements on the impl of `Resource` for `WinitWindows`
note: required by a bound in `bevy::prelude::Res`
   --> /Users/<user>/.cargo/git/checkouts/bevy-f7ffde730c324c74/c747cc5/crates/bevy_ecs/src/system/system_param.rs:203:23
    |
203 | pub struct Res<'w, T: Resource> {
    |                       ^^^^^^^^ required by this bound in `bevy::prelude::Res`

error[E0277]: `*const ()` cannot be shared between threads safely
   --> src/systems.rs:344:27
    |
344 |     winit_windows: Option<Res<WinitWindows>>,
    |                           ^^^^^^^^^^^^^^^^^ `*const ()` cannot be shared between threads safely
    |
    = help: within `WinitWindows`, the trait `Sync` is not implemented for `*const ()`
    = note: required because it appears within the type `PhantomData<*const ()>`
    = note: required because it appears within the type `WinitWindows`
    = note: required because of the requirements on the impl of `Resource` for `WinitWindows`
note: required by a bound in `bevy::prelude::Res`
   --> /Users/<user>/.cargo/git/checkouts/bevy-f7ffde730c324c74/c747cc5/crates/bevy_ecs/src/system/system_param.rs:203:23
    |
203 | pub struct Res<'w, T: Resource> {
    |                       ^^^^^^^^ required by this bound in `bevy::prelude::Res`

Some errors have detailed explanations: E0277, E0432.
For more information about an error, try `rustc --explain E0277`.

Internal handling of texture ids

I have a dynamic number of images I want to show using bevy_egui. I am trying to preview single frames of animations. I basically have a handles: Vec<Handle<Image>>. To display that with bevy_egui, I figured I have to do something like

for (index, handle) in handles {
    egui_context.set_egui_texture(index as u64, handle)
}

However, If I try to do that with my next animation, the texture ids are already occupied by the previous animation. Thus I would need to have my program remember the texture ids already in use.

Could EguiContext do that internally for me? I imagine a function like

impl EguiContext {
    /// looks for the next free id and returns the TextureId that you can directly use with Ui::image
    pub fn add_texture(&mut self, texture: Handle<Image>) -> TextureId;
}

Benefits:

  • The consumer does not need to remember occupied ids. (EguiContext does that implicitly already anway.)
  • The consumer does not need to know how to generate TextureIds. It would be similar to Bevy's Handles: I can ask bevy_egui to take care of an image, I get the id and can use it without ever looking into it.

bevy games integration in canvas

User interface is very, very dark

I copied and ran the ui.rs example and the result is extremely dark, on the verge of illegible:
image

This is much darker than the screenshots posted both here and in the egui repository, so I imagine that this is a bug. Apart from everything being almost impossible to see, the ui seems to work fine.

I am using the following setup:

  • Rust 2021
  • bevy 0.7
  • bevy_egui 0.13.0
  • Windows 10, Vulkan on AMD Radeon Pro WX3200 Graphics

Update:
All the other examples are darker as well.

Compile Errors with bevy_dylib on Windows10 - rust-lld: error: too many exported symbols (max 65535)

I'm trying to get the bevy dynamic building feature working for faster build times. I have been able to get the bevy crate's examples building with the dynamic feature , so I know it is possible for bevy to build with dynamic on my machine with the following these steps

bevyengine/bevy#1126
https://bevyengine.org/learn/book/getting-started/setup/ - Fast Compile section

However, the bevy_egui is not working with those same steps. It does work with the dynamic feature removed. I've created a fork showing the changes I've made, just adding the fast compile .carg/config.toml file & "dynamic" feature to bevy dependency.

https://github.com/bayswaterpc/bevy_egui

It gives the following error when building any of the example targets
bevy_egui dynamic bevy error blob.txt

If anyone has been able to get this working on Windows would love some tips.

calling `EguiContext::ctx` from a startup system

I would like to globally modify some egui visuals, I tried using this

fn ui_setup(egui_context: ResMut<EguiContext>) {
    egui_context.ctx().set_visuals(egui::Visuals {
        window_shadow: Default::default(),
        ..Default::default()
    });
}

as a startup system. (Just added this to the simple.rs example.) Unfortunately, this results in a panic:

thread 'main' panicked at '`EguiContext::ctx()` called before the ctx has been initialized. Consider moving your UI system to `CoreStage::Update` or run you system after `EguiSystem::BeginFrame`.'

The message here seems to be relevant to regular systems, but not to startup systems. How do I ensure that my startup system runs after the context has been initialized?

Mouse up events are ignored in browsers if cursor leaves a focused window

Introduction of the a3d113a commit prevents Egui from resetting the latest_pos field of the PointerState struct, which makes it possible to continue dragging a slider, for example, when a cursor leaves a window (which fixed #61). But after this change, it became apparent that Bevy often fails to emit a mouse up event if it happened outside of a focused window (so far I believe it affects only browsers), which results in behaviour similar to this one in the video: #61 (comment).

Font Panic

2022-06-01T20:00:59.156772Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon RX 6900 XT", vendor: 4098, device: 29631, device_type: DiscreteGpu, backend: Vulkan }
thread 'Compute Task Pool (2)' panicked at 'No fonts available until first call to Context::run()', C:\Users\drewr\.cargo\registry\src\github.com-1ecc6299db9ec823\egui-0.18.1\src\context.rs:535:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'task has failed', C:\Users\drewr\.cargo\registry\src\github.com-1ecc6299db9ec823\async-task-4.2.0\src\task.rs:425:45
error: process didn't exit successfully: `target\debug\spacebandits.exe` (exit code: 101)
PS C:\Users\drewr\Documents\Projects\spacebandits>

Can't run egui system in `CoreStage::PostUpdate`: 'already mutably borrowed',

Hello,

Hit this one in the process of porting my game to Bevy 0.6. I have an egui system that needs to access context.ctx().output().events in CoreSystem::PostUpdate. This was doable in 0.5, but in 0.6 gives:

thread 'Compute Task Pool (1)' panicked at 'already mutably borrowed', C:\Users\Nolan\scoop\persist\rustup\.cargo\registry\src\github.com-1ecc6299db9ec823\atomic_refcell-0.1.8\src\lib.rs:151:23                                                                         
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace                                                        

I can send you the full stacktrace if you like, but I do have a sample that reproduces this. https://github.com/ndarilek/bevy_egui_a11y has a main branch that works against Bevy 0.5, and a bevy-0.6 branch that crashes immediately on launch.

I tried moving this system around a bit, but it really needs to run with these events populated, and none of the simpler stage moves (I.e. just running it in Update or PreUpdate) did anything other than prevent the crash. I suppose I could manually order each UI system to run before the screen reader, but that'd be a lot of code on each system when what I really want to do is add the screen reader before whatever egui needs to do to clean up the context.

Any idea why this stopped working? Are borrows handled differently in 0.9 and 0.10 in some way that might account for this?

Thanks a bunch!

wgpu error: Validation Error in Windows 10

The issue is in Windows 10, and the Deepin Linux is ok
bevy or egui master code examples are Ok

in current bevy_egui example,
cargo run --example simple
cargo run --example ui

When clicking minimize on the title bar, an error occurs,

    Finished dev [unoptimized + debuginfo] target(s) in 15.41s
     Running `target\debug\examples\simple.exe`
2022-01-17T14:30:40.319193Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 2080 Ti", vendor: 4318, device: 7687, device_type: DiscreteGpu, backend: Vulkan }
2022-01-17T14:30:45.951209Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'main' panicked at 'wgpu error: Validation Error

Caused by:
    In a RenderPass
      note: encoder = `<CommandBuffer-(0, 305, Vulkan)>`
    In a set_scissor_rect command
    Invalid ScissorRect parameters

', C:\Users\Administrator\.cargo\registry\src\rsproxy.cn-8f6827c7555bfaf8\wgpu-0.12.0\src\backend\direct.rs:2273:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\examples\simple.exe` (exit code: 101)

Mouse events are ignored after cursor leaves window

Before a496e49 it was possible to start dragging somewhere in the window (for example a slider), then move the cursor out of the window while still having the mouse button pressed and then returning.

After the change, the mouse events will stop firing as soon as the cursor leaves the window.

Removing the if in

a496e49#diff-420f4e08a25299e0e1fb09f4757e1d5d027a2278f37030c09ab9c06786cfa52eR155-R157

fixes this, although I'm not sure why, because the if condition is only false for one frame.

Before:

mouse_out_of_window.mp4

After:

mouse_after.mp4

UI elements cannot keep focus if system is on main thread.

In order to be able to open a native file dialog (I used the native-dialog crate) I had to put the ui system on the main thread.

The reason being that on Mac, opening the file dialog is only supported from the main thread.

When the ui system is used in a single_threaded system stage it keeps on losing focus from all widgets.

Screen.Recording.2022-02-19.at.00.32.09.mov

Minimal reproduction code:
src/main.rs:

use bevy::prelude::*;
use bevy_egui::{egui, EguiContext, EguiPlugin};

#[derive(Debug, Hash, PartialEq, Eq)]
pub struct MainThread;

impl StageLabel for MainThread {
    fn dyn_clone(&self) -> Box<dyn StageLabel> {
        Box::new(MainThread)
    }
}

fn main() {
    App::new()
        .add_stage(MainThread, SystemStage::single_threaded())
        .add_plugins(DefaultPlugins)
        .add_plugin(EguiPlugin)
        .add_system_to_stage(MainThread, ui_system) // <- focus will be lost
        // .add_system(ui_system) // <- focus works fine
        .run();
}

fn ui_system(mut egui_context: ResMut<EguiContext>) {
    egui::Window::new("Whatever").show(egui_context.ctx_mut(), |ui| {
        ui.text_edit_singleline(&mut String::from("Hello, World!"));
    });
}

Cargo.toml:

[package]
name = "app"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = { version = "0.6.1" }
bevy_egui = "0.11.1"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.