Add ReflectComponent registration for Sprite (#8207)

# 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>
This commit is contained in:
Sergey Vikhirev 2023-03-28 01:18:10 +04:00 committed by GitHub
parent aef643cf50
commit 9784186fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
@ -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]