mirror of
https://github.com/bevyengine/bevy
synced 2024-11-24 21:53:07 +00:00
Reflect derived traits on all components and resources: bevy_sprite (#15227)
Solves https://github.com/bevyengine/bevy/issues/15187 for bevy_sprite
This commit is contained in:
parent
274c97d415
commit
07e79f3e9f
5 changed files with 12 additions and 8 deletions
|
@ -78,7 +78,7 @@ pub enum SpriteSystem {
|
|||
///
|
||||
/// Right now, this is used for `Text`.
|
||||
#[derive(Component, Reflect, Clone, Copy, Debug, Default)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct SpriteSource;
|
||||
|
||||
/// A convenient alias for `With<Mesh2dHandle>>`, for use with
|
||||
|
|
|
@ -52,7 +52,7 @@ use crate::Material2dBindGroupId;
|
|||
///
|
||||
/// It wraps a [`Handle<Mesh>`] to differentiate from the 3d pipelines which use the handles directly as components
|
||||
#[derive(Default, Clone, Component, Debug, Reflect, PartialEq, Eq, Deref, DerefMut)]
|
||||
#[reflect(Default, Component)]
|
||||
#[reflect(Default, Component, Debug, PartialEq)]
|
||||
pub struct Mesh2dHandle(pub Handle<Mesh>);
|
||||
|
||||
impl From<Handle<Mesh>> for Mesh2dHandle {
|
||||
|
|
|
@ -56,7 +56,7 @@ impl Plugin for Wireframe2dPlugin {
|
|||
///
|
||||
/// This requires the [`Wireframe2dPlugin`] to be enabled.
|
||||
#[derive(Component, Debug, Clone, Default, Reflect, Eq, PartialEq)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug, PartialEq)]
|
||||
pub struct Wireframe2d;
|
||||
|
||||
/// Sets the color of the [`Wireframe2d`] of the entity it is attached to.
|
||||
|
@ -65,7 +65,7 @@ pub struct Wireframe2d;
|
|||
///
|
||||
/// This overrides the [`Wireframe2dConfig::default_color`].
|
||||
#[derive(Component, Debug, Clone, Default, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct Wireframe2dColor {
|
||||
pub color: Color,
|
||||
}
|
||||
|
@ -75,11 +75,11 @@ pub struct Wireframe2dColor {
|
|||
///
|
||||
/// This requires the [`Wireframe2dPlugin`] to be enabled.
|
||||
#[derive(Component, Debug, Clone, Default, Reflect, Eq, PartialEq)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug, PartialEq)]
|
||||
pub struct NoWireframe2d;
|
||||
|
||||
#[derive(Resource, Debug, Clone, Default, ExtractResource, Reflect)]
|
||||
#[reflect(Resource)]
|
||||
#[reflect(Resource, Debug, Default)]
|
||||
pub struct Wireframe2dConfig {
|
||||
/// Whether to show wireframes for all 2D meshes.
|
||||
/// Can be overridden for individual meshes by adding a [`Wireframe2d`] or [`NoWireframe2d`] component.
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::TextureSlicer;
|
|||
///
|
||||
/// This is commonly used as a component within [`SpriteBundle`](crate::bundle::SpriteBundle).
|
||||
#[derive(Component, Debug, Default, Clone, Reflect)]
|
||||
#[reflect(Component, Default)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
#[repr(C)]
|
||||
pub struct Sprite {
|
||||
/// The sprite's color tint
|
||||
|
@ -43,7 +43,7 @@ impl Sprite {
|
|||
|
||||
/// Controls how the image is altered when scaled.
|
||||
#[derive(Component, Debug, Clone, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[reflect(Component, Debug)]
|
||||
pub enum ImageScaleMode {
|
||||
/// The texture will be cut in 9 slices, keeping the texture in proportions on resize
|
||||
Sliced(TextureSlicer),
|
||||
|
@ -62,6 +62,7 @@ pub enum ImageScaleMode {
|
|||
/// How a sprite is positioned relative to its [`Transform`](bevy_transform::components::Transform).
|
||||
/// It defaults to `Anchor::Center`.
|
||||
#[derive(Component, Debug, Clone, Copy, PartialEq, Default, Reflect)]
|
||||
#[reflect(Component, Default, Debug, PartialEq)]
|
||||
#[doc(alias = "pivot")]
|
||||
pub enum Anchor {
|
||||
#[default]
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use bevy_asset::{Asset, AssetId, Assets, Handle};
|
||||
use bevy_ecs::component::Component;
|
||||
use bevy_ecs::reflect::ReflectComponent;
|
||||
use bevy_math::{URect, UVec2};
|
||||
use bevy_reflect::std_traits::ReflectDefault;
|
||||
use bevy_reflect::Reflect;
|
||||
use bevy_render::texture::Image;
|
||||
use bevy_utils::HashMap;
|
||||
|
@ -142,6 +144,7 @@ impl TextureAtlasLayout {
|
|||
/// - [`sprite animation event example`](https://github.com/bevyengine/bevy/blob/latest/examples/2d/sprite_animation.rs)
|
||||
/// - [`texture atlas example`](https://github.com/bevyengine/bevy/blob/latest/examples/2d/texture_atlas.rs)
|
||||
#[derive(Component, Default, Debug, Clone, Reflect)]
|
||||
#[reflect(Component, Default, Debug)]
|
||||
pub struct TextureAtlas {
|
||||
/// Texture atlas layout handle
|
||||
pub layout: Handle<TextureAtlasLayout>,
|
||||
|
|
Loading…
Reference in a new issue