-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bevy support? #124
Comments
Seems to work on the basic example - problem must be on my end. Made a pr for an example |
Would appreciate some input on a very odd issue. In the sample code I wrote above (that works) - the StableGraph is
In my personal code I create the stable graph async. Before creating the
The two stable graphs are identical. After adding them to egui_graphs they're also identical Sample code
My code that doesn't work
However for my code a central panel appears but no graph appears. #[derive(Component)]
pub struct EguiGraph(egui_graphs::Graph<Properties, Properties, Directed, u16>);
impl Default for EguiGraph {
fn default() -> Self {
Self(egui_graphs::Graph::new(StableGraph::default()))
}
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(EntropyPlugin::<WyRand>::new())
.add_plugins(ProcGenPlugin)
.add_plugins(EguiPlugin)
.add_systems(Update, (on_gen_map_button, graph_update))
.add_systems(Update, on_graph_created)
.run();
}
fn on_gen_map_button(
mut commands: Commands,
mut contexts: EguiContexts,
mut gen_event_ew: EventWriter<GenEvent>,
) {
let ctx = contexts.ctx_mut();
egui::Window::new("grew_ui").show(ctx, |ui| {
if ui.button("Generate Map").clicked() {
let entity = commands.spawn(EguiGraph::default());
let map_config = MapConfig { difficulty: 1 };
gen_event_ew.send(GenEvent {
entity: entity.id(),
kind: GenKind::Map(map_config),
});
}
});
}
fn graph_update(mut contexts: EguiContexts, mut q_egui_graph: Query<&mut EguiGraph>) {
let ctx = contexts.ctx_mut();
if let Ok(mut egui_graph) = q_egui_graph.get_single_mut() {
println!("egui_graph: {:?}", egui_graph.0);
egui::CentralPanel::default().show(ctx, |ui| {
ui.add(&mut GraphView::<
_,
_,
_,
_,
egui_graphs::DefaultNodeShape,
egui_graphs::DefaultEdgeShape<_>,
>::new(&mut egui_graph.0));
});
}
}
fn on_graph_created(mut q_graphs: Query<(&mut EguiGraph, &DiGraph), Added<DiGraph>>) {
for (mut egui_graph, digraph) in q_graphs.iter_mut() {
println!("on_graph_created: {:?}", digraph.0);
egui_graph.0 = egui_graphs::Graph::from(&digraph.0);
}
} Any ideas? |
Try initializing ui.add(
&mut GraphView::<_, _, _, _, DefaultNodeShape, DefaultEdgeShape<_>>::new(
&mut graph_provider.g,
)
.with_navigations(
&SettingsNavigation::default()
.with_fit_to_screen_enabled(false)
),
) There is a know issue #116 which can cause automatic |
Issue is particularly bad if you initialize Take your time - setting the initial value to some simple graph works okay as a workaround for now. |
Bevy support seems to work - closing this and opening: #127 for the specific bug I ran into |
Is eframe required for GraphView to work? I'm trying to get this to work via bevy_egui - a central panel is created but I don't see a graph. I'll do some digging on my own but any additional info would be appreciated.
The text was updated successfully, but these errors were encountered: