Skip to content

Commit

Permalink
simpler serialization example
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Aug 8, 2024
1 parent aa0ee14 commit 789a2bc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bevy_rapier2d/examples/serialization2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Example for RapierContext serialization, run with `--features serde-serialize`.

use bevy::prelude::*;
use bevy::MinimalPlugins;
use bevy_rapier2d::prelude::*;

/// Note: This will end up in duplication for testbed, but that's more simple.
Expand All @@ -14,24 +15,23 @@ fn main() {
0xFF as f32 / 255.0,
)))
.add_plugins((
DefaultPlugins,
MinimalPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
))
.add_systems(Startup, (joints2::setup_graphics, joints2::setup_physics))
.add_systems(Startup, joints2::setup_physics)
.add_systems(PostUpdate, print_physics)
.add_systems(Last, quit)
.run();
}

pub fn print_physics(context: Res<RapierContext>) {
#[cfg(feature = "serde-serialize")]
info!(
println!(
"{}",
serde_json::to_string_pretty(&(*context)).expect("Unable to serialize `RapierContext`")
);
#[cfg(not(feature = "serde-serialize"))]
error!("Example 'serialization' should be run with '--features serde-serialize'.");
panic!("Example 'serialization' should be run with '--features serde-serialize'.");
}

fn quit(mut exit_event: EventWriter<AppExit>) {
Expand Down

0 comments on commit 789a2bc

Please sign in to comment.