Crates.io | renet_visualizer |
lib.rs | renet_visualizer |
version | 0.0.9 |
source | src |
created_at | 2022-06-26 20:36:50.311824 |
updated_at | 2024-07-20 17:33:04.018198 |
description | Egui metrics visualizer for the renet crate: Server/Client network library for multiplayer games |
homepage | |
repository | https://github.com/lucaspoffo/renet |
max_upload_size | |
id | 613695 |
size | 19,698 |
A egui metrics visualizer for the renet crate with simple usage.
Client
let mut visualizer = RenetClientVisualizer::<200>::new(RenetVisualizerStyle::default());
// ..
loop {
// Update Renet Client
client.update(delta).unwrap();
// Add metrics to the visualizer
visualizer.add_network_info(client.network_info());
// Draws a new egui window with the metrics
visualizer.show_window(egui_ctx);
// ..
}
Server
let mut visualizer = RenetServerVisualizer::<200>::new(RenetVisualizerStyle::default());
// ..
loop {
// Update Renet Server
server.update(delta).unwrap();
// Add/Remove clients from the visualizer
while let Some(event) = server.get_event() {
match event {
ServerEvent::ClientConnected(client_id, user_data) => {
visualizer.add_client(client_id);
// ...
}
ServerEvent::ClientDisconnected(client_id) => {
visualizer.remove_client(client_id);
// ...
}
}
}
// Add all clients metrics to the visualizer
visualizer.update(&server);
// Draws a new egui window with all clients metrics
visualizer.show_window(egui_ctx);
// ..
}