Skip to content

Commit f70148d

Browse files
committed
Add serialize feature
1 parent 0852ce8 commit f70148d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Cargo.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@ version = "0.1.0"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
authors = ["Joona Aalto <jondolf.dev@gmail.com>"]
7-
description = "A general-purpose transform interpolation plugin for fixed timesteps for the Bevy game engine"
7+
description = "Transform interpolation for fixed timesteps for the Bevy game engine"
88
documentation = "https://docs.rs/bevy_transform_interpolation"
99
repository = "https://github.com/Jondolf/bevy_transform_interpolation"
1010
readme = "README.md"
1111
keywords = ["gamedev", "easing", "bevy"]
1212
categories = ["game-development"]
1313

14+
[features]
15+
default = []
16+
17+
# Enable data serialization/deserialization using `serde`.
18+
serialize = ["dep:serde", "bevy/serialize"]
19+
1420
[dependencies]
1521
bevy = { version = "0.15", default-features = false }
1622

23+
# Serialization
24+
serde = { version = "1.0", default-features = false, optional = true }
25+
1726
[dev-dependencies]
1827
bevy = { version = "0.15", default-features = false, features = [
1928
"bevy_core_pipeline",

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ impl VelocitySource for () {
419419
/// On its own, this component is not updated automatically. Enable an easing backend
420420
/// such as the [`TransformInterpolationPlugin`] to perform automatic interpolation.
421421
#[derive(Component, Clone, Copy, Debug, Default, PartialEq, Reflect)]
422+
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
423+
#[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))]
422424
#[reflect(Component, Debug, Default)]
423425
pub struct TranslationEasingState {
424426
/// The start translation for the interpolation.
@@ -433,6 +435,8 @@ pub struct TranslationEasingState {
433435
/// On its own, this component is not updated automatically. Enable an easing backend
434436
/// such as the [`TransformInterpolationPlugin`] to perform automatic interpolation.
435437
#[derive(Component, Clone, Copy, Debug, Default, PartialEq, Reflect)]
438+
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
439+
#[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))]
436440
#[reflect(Component, Debug, Default)]
437441
pub struct RotationEasingState {
438442
/// The start rotation for the interpolation.
@@ -447,6 +451,8 @@ pub struct RotationEasingState {
447451
/// On its own, this component is not updated automatically. Enable an easing backend
448452
/// such as the [`TransformInterpolationPlugin`] to perform automatic interpolation.
449453
#[derive(Component, Clone, Copy, Debug, Default, PartialEq, Reflect)]
454+
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
455+
#[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))]
450456
#[reflect(Component, Debug, Default)]
451457
pub struct ScaleEasingState {
452458
/// The start scale for the interpolation.

0 commit comments

Comments
 (0)