Skip to content

Commit 2e1acb9

Browse files
authored
added serde(default) to Transform (#23474)
# Objective Need serde(Default) for Transform. I think it would be very useful in cases where someone wants to add an object to their scene but doesn't want to have to specify rotation or scale, e.g.: ``` 5: ( components: { "common::types::GameObjectKind": Rifle, "bevy_transform::components::transform::Transform": ( translation: (1.5, 800.0, 0.0), ), }, ), ``` ## Solution Added `#[cfg_attr(feature = "serialize", serde(default))]` before the Transform struct. ## Testing Successfully built bevy, but haven't tested extensively. Theoretically shouldn't break existing functionality, since Deriving Transform was invalid before this PR.
1 parent 09ef09e commit 2e1acb9

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

crates/bevy_transform/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ bevy_math = { path = "../bevy_math", version = "0.19.0-dev", default-features =
2929
"approx",
3030
] }
3131
approx = "0.5.1"
32+
ron = "0.8"
3233

3334
[features]
3435
# Turning off default features leaves you with a barebones

crates/bevy_transform/src/components/transform.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn assert_is_normalized(message: &str, length_squared: f32) {
6868
/// [transform_example]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs
6969
#[derive(Debug, PartialEq, Clone, Copy)]
7070
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
71+
#[cfg_attr(feature = "serialize", serde(default))]
7172
#[cfg_attr(
7273
feature = "bevy-support",
7374
derive(Component),

0 commit comments

Comments
 (0)