setzer22 / egui_node_graph

Build your node graph applications in Rust, using egui
MIT License
711 stars 132 forks source link

Please add minimalistic example using bevy_egui #64

Closed trsh closed 1 year ago

trsh commented 1 year ago

I tried to figure it out my self, but some-have failed.

setzer22 commented 1 year ago

I don't have time to add a bevy example right now :sweat_smile: but if anyone wants to contribute one, it's more than welcome!

In the meantime, perhaps you can share your attempt @trsh? I may be able to help, but I can't think of anything where bevy_egui would make things different than the official example.

trsh commented 1 year ago
error[E0053]: method `value_widget` has an incompatible type for trait
  --> src\node_graph.rs:89:54
   |
89 |     fn value_widget(&mut self, param_name: &str, ui: &mut egui::Ui) -> Vec<MyResponse> {
   |                                                      ^^^^^^^^^^^^^
   |                                                      |
   |                                                      expected struct `egui::ui::Ui`, found struct `Ui`
   |                                                      help: change the parameter type to match the trait: `&mut egui::ui::Ui`
   |
   = note: expected fn pointer `fn(&mut MyValueType, &str, &mut egui::ui::Ui) -> std::vec::Vec<_>`
              found fn pointer `fn(&mut MyValueType, &str, &mut Ui) -> std::vec::Vec<_>`

I think it expects the Ui from eframe

Tsudico commented 1 year ago

I think you are missing a bit from line 89. It should look like:

     fn value_widget(&mut self, param_name: &str, ui: &mut egui::ui::Ui) -> Vec<MyResponse> {

Do you have a link to the project on github or a way we could see more details on what you are trying to do beyond the small error quoted?

trsh commented 1 year ago
error[E0053]: method `value_widget` has an incompatible type for trait
  --> src\node_graph.rs:88:54
   |
88 |     fn value_widget(&mut self, param_name: &str, ui: &mut egui::ui::Ui) -> Vec<MyResponse> {
   |                                                      ^^^^^^^^^^^^^^^^^
   |                                                      |
   |                                                      expected struct `egui::ui::Ui`, found struct `Ui`
   |                                                      help: change the parameter type to match the trait: `&mut egui::ui::Ui`
   |
   = note: expected fn pointer `fn(&mut MyValueType, &str, &mut egui::ui::Ui) -> std::vec::Vec<_>`
              found fn pointer `fn(&mut MyValueType, &str, &mut Ui) -> std::vec::Vec<_>`

Imports

use egui::{self, DragValue, TextStyle};
use egui_node_graph::*;

I dont get it. I feed exactly the type it asks. I do not have a repo.

Tsudico commented 1 year ago

Bevy_egui uses it's own egui crate as seen in this example code:

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

https://github.com/mvlabat/bevy_egui

Were you able to get a minimum bevy_egui example to run?

trsh commented 1 year ago

Yes. It works. So maybe these egui versions are clashing? beavy_egui has depency

egui = { version = "0.19.0", default-features = false, features = ["bytemuck"] }

So I think it just exposes it

trsh commented 1 year ago

Tried to use like this

use bevy_egui::{
    egui::{self, DragValue, TextStyle},
    EguiContext, EguiPlugin,
};

and removed egui dep from my project. Same issue.

trsh commented 1 year ago

egui_node_graph has "egui 0.18.1" depency, bevy_egui "egui 0.19.0". Thats what I see in cargo.lock

Tsudico commented 1 year ago

You can try getting a specific commit of egui_node_graph, like: https://github.com/setzer22/egui_node_graph/commit/b1deb59af13e51edda0fbc69e29fc235b52896c6 so that they are both using egui 0.19.

You would have to update your egui_node_graph dependency in cargo.toml:

egui_node_graph= { git = "https://github.com/setzer22/egui_node_graph.git", rev = "b1deb59" }
trsh commented 1 year ago

Yeah. Already took latest from git and now it works. Different versions of egui was the issue

setzer22 commented 1 year ago

Glad you figured it out! :tada: Ending up with different versions of a crate on the same project is always a headache