Skip to content

Commit

Permalink
Add ReflectComponent registration for Sprite (#8207)
Browse files Browse the repository at this point in the history
# Objective

- `Sprite` components are not included in scene (de)serialization.
- Fixes #8206

## Solution

- Add `#[reflect(Component, Default)]` to `Sprite`
- Add `#[derive(FromReflect)]` to `Sprite` and `Anchor`

---------

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
  • Loading branch information
BorMor and cart authored Mar 27, 2023
1 parent aef643c commit 9784186
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/bevy_sprite/src/sprite.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use bevy_ecs::component::Component;
use bevy_ecs::{component::Component, reflect::ReflectComponent};
use bevy_math::{Rect, Vec2};
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect};
use bevy_render::color::Color;

#[derive(Component, Debug, Default, Clone, Reflect)]
#[derive(Component, Debug, Default, Clone, Reflect, FromReflect)]
#[reflect(Component, Default)]
#[repr(C)]
pub struct Sprite {
/// The sprite's color tint
Expand All @@ -24,7 +25,7 @@ pub struct Sprite {

/// How a sprite is positioned relative to its [`Transform`](bevy_transform::components::Transform).
/// It defaults to `Anchor::Center`.
#[derive(Component, Debug, Clone, Default, Reflect)]
#[derive(Component, Debug, Clone, Default, Reflect, FromReflect)]
#[doc(alias = "pivot")]
pub enum Anchor {
#[default]
Expand Down

0 comments on commit 9784186

Please sign in to comment.