Skip to content

Commit 7fdc6c7

Browse files
chescockItsDoot
authored andcommitted
impl Reflect and Debug for Mesh2dHandle (bevyengine#4368)
# Objective An entity spawned with `MaterialMesh2dBundle<M>` cannot be saved and spawned using `DynamicScene` because the `Mesh2dHandle` component does not `impl Reflect`. ## Solution Add `#[derive(Reflect)]` and `#[reflect(Component)]` to `Mesh2dHandle`, and call `register_type` in `SpritePlugin`. Also add `#[derive(Debug)]` since I'm touching the `derive`s anyway.
1 parent 9abd462 commit 7fdc6c7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

crates/bevy_sprite/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl Plugin for SpritePlugin {
5757
shaders.set_untracked(SPRITE_SHADER_HANDLE, sprite_shader);
5858
app.add_asset::<TextureAtlas>()
5959
.register_type::<Sprite>()
60+
.register_type::<Mesh2dHandle>()
6061
.add_plugin(Mesh2dRenderPlugin)
6162
.add_plugin(ColorMaterialPlugin);
6263

crates/bevy_sprite/src/mesh2d/mesh.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use bevy_ecs::{
55
system::{lifetimeless::*, SystemParamItem},
66
};
77
use bevy_math::{Mat4, Size};
8-
use bevy_reflect::TypeUuid;
8+
use bevy_reflect::{Reflect, TypeUuid};
99
use bevy_render::{
1010
mesh::{GpuBufferInfo, Mesh, MeshVertexBufferLayout},
1111
render_asset::RenderAssets,
@@ -22,7 +22,8 @@ use bevy_transform::components::GlobalTransform;
2222
/// Component for rendering with meshes in the 2d pipeline, usually with a [2d material](crate::Material2d) such as [`ColorMaterial`](crate::ColorMaterial).
2323
///
2424
/// It wraps a [`Handle<Mesh>`] to differentiate from the 3d pipelines which use the handles directly as components
25-
#[derive(Default, Clone, Component)]
25+
#[derive(Default, Clone, Component, Debug, Reflect)]
26+
#[reflect(Component)]
2627
pub struct Mesh2dHandle(pub Handle<Mesh>);
2728

2829
impl From<Handle<Mesh>> for Mesh2dHandle {

0 commit comments

Comments
 (0)