I'm trying to integrate it into my own codebase - in my code I create the entity async (not in Startup) as so
#[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),
});
}
});
}