Fix color serialization and enable serde feature

This commit is contained in:
Elias Stepanik 2025-06-09 19:29:18 +02:00
parent 78ee3483d7
commit e406ac15cb
2 changed files with 4 additions and 3 deletions

View File

@ -9,7 +9,7 @@ build = "build.rs"
[dependencies]
bevy = { version = "0.15.1", features = ["jpeg", "trace_tracy", "trace_tracy_memory"] }
bevy = { version = "0.15.1", features = ["jpeg", "trace_tracy", "trace_tracy_memory", "serialize"] }
rand = "0.8.5"
serde = { version = "1.0", features = ["derive"] }
toml = "0.8"
@ -21,3 +21,4 @@ smallvec = "1.14.0"
once_cell = "1.21.3"
rayon = "1.10.0"
bincode = "1.3"

View File

@ -7,7 +7,7 @@ fn serialize_color<S>(color: &Color, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let [r, g, b, a] = color.as_linear_rgba_f32();
let [r, g, b, a] = color.to_linear().to_f32_array();
[r, g, b, a].serialize(serializer)
}
@ -16,7 +16,7 @@ where
D: Deserializer<'de>,
{
let arr: [f32; 4] = Deserialize::deserialize(deserializer)?;
Ok(Color::rgba_linear(arr[0], arr[1], arr[2], arr[3]))
Ok(Color::linear_rgba(arr[0], arr[1], arr[2], arr[3]))
}