vladbat00 / bevy_egui

This crate provides an Egui integration for the Bevy game engine. 🇺🇦 Please support the Ukrainian army: https://savelife.in.ua/en/
MIT License
974 stars 252 forks source link

How to plug bevy App into Egui App > #308

Closed Shrav108 closed 2 months ago

Shrav108 commented 2 months ago

Hi, can anyone tell me how to plug a bevy app inside an egui app ? I want to display .stl file in my egui app

364684534-788b384f-4de3-4534-b296-64760cef93f8

vladbat00 commented 2 months ago

Hi. Take a look at the examples/side_panel.rs and examples/render_to_image_widget.rs examples. These have two different approaches: the side_panel one just renders side panels on top of Bevy while shifting the camera a bit (based on the width of the side panels); the examples/render_to_image_widget.rs shows how to render something to a texture and then show that texture as an image in Egui.

The first one should be easier to set up, even though it's a bit further from the "Bevy app inside Egui" idea, it should be visually indistinguishable.

Shrav108 commented 2 months ago

These examples are fine. But they are using egui plugin and creating the app. What I would like is that I want to plug the bevy engine into my egui app. My egui app has many sub apps embedded. I want to plug this feature into that egui app. How do I do that ?

vladbat00 commented 2 months ago

What exactly do you mean by Egui app? Are you using some different backend like eframe and want to integrate a Bevy app into it? If so, I don't know of any easy way to do that. Any particular reason why you want to use a different backed for the main window? If you are going to use Bevy, maybe it's easier to just use it as a main backend instead - can that work for you?

Shrav108 commented 2 months ago

Egui app is :

fn main() -> eframe::Result {
    let options = eframe::NativeOptions {
       // CODE 
    };

    eframe::run_native(
        "My egui App",
        options,
        Box::new(|cc| {

            Ok(Box::<MyApp>::default())

        }),
    )
}

struct MyApp {
   // EMBED BEVY APP HERE 
}

This is my backend. Bevy app to be embedded in MyApp.

I already have eframe as backend. I can't use bevy as main backend.

vladbat00 commented 2 months ago

Sry, I'm afraid this is not something I can help you with. bevy_egui is meant to be used only with Bevy as a main backend. I don't think the opposite is really feasible

Shrav108 commented 2 months ago

Thank you for your response. I guess I have to look for other ways.