Skip to content

Commit

Permalink
Add Reflection Macros to TextureAtlasSprite (#8428)
Browse files Browse the repository at this point in the history
# Objective

Add Reflection to `TextureAtlasSprite` to bring it inline with `Sprite`

## Solution

Addition of appropriate macros to the type

---

## Changelog

`#[reflect(Component)]` and derive `FromReflect` for
`TextureAtlasSprite`
Added `TextureAtlasSprite` to the TypeRegistry
  • Loading branch information
TheTacBanana committed Apr 17, 2023
1 parent 30ac157 commit 764961b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/bevy_sprite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl Plugin for SpritePlugin {
app.add_asset::<TextureAtlas>()
.register_asset_reflect::<TextureAtlas>()
.register_type::<Sprite>()
.register_type::<TextureAtlasSprite>()
.register_type::<Anchor>()
.register_type::<Mesh2dHandle>()
.add_plugin(Mesh2dRenderPlugin)
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_sprite/src/texture_atlas.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::Anchor;
use bevy_asset::Handle;
use bevy_ecs::component::Component;
use bevy_ecs::{component::Component, reflect::ReflectComponent};
use bevy_math::{Rect, Vec2};
use bevy_reflect::{FromReflect, Reflect, TypeUuid};
use bevy_render::{color::Color, texture::Image};
Expand All @@ -23,7 +23,8 @@ pub struct TextureAtlas {
pub(crate) texture_handles: Option<HashMap<Handle<Image>, usize>>,
}

#[derive(Component, Debug, Clone, Reflect)]
#[derive(Component, Debug, Clone, Reflect, FromReflect)]
#[reflect(Component)]
pub struct TextureAtlasSprite {
/// The tint color used to draw the sprite, defaulting to [`Color::WHITE`]
pub color: Color,
Expand Down

0 comments on commit 764961b

Please sign in to comment.