impl Reflect and Debug for Mesh2dHandle (#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.
This commit is contained in:
parent
3537c6ae2d
commit
2b35dbabfd
@ -57,6 +57,7 @@ impl Plugin for SpritePlugin {
|
|||||||
shaders.set_untracked(SPRITE_SHADER_HANDLE, sprite_shader);
|
shaders.set_untracked(SPRITE_SHADER_HANDLE, sprite_shader);
|
||||||
app.add_asset::<TextureAtlas>()
|
app.add_asset::<TextureAtlas>()
|
||||||
.register_type::<Sprite>()
|
.register_type::<Sprite>()
|
||||||
|
.register_type::<Mesh2dHandle>()
|
||||||
.add_plugin(Mesh2dRenderPlugin)
|
.add_plugin(Mesh2dRenderPlugin)
|
||||||
.add_plugin(ColorMaterialPlugin);
|
.add_plugin(ColorMaterialPlugin);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use bevy_ecs::{
|
|||||||
system::{lifetimeless::*, SystemParamItem},
|
system::{lifetimeless::*, SystemParamItem},
|
||||||
};
|
};
|
||||||
use bevy_math::{Mat4, Size};
|
use bevy_math::{Mat4, Size};
|
||||||
use bevy_reflect::TypeUuid;
|
use bevy_reflect::{Reflect, TypeUuid};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
mesh::{GpuBufferInfo, Mesh, MeshVertexBufferLayout},
|
mesh::{GpuBufferInfo, Mesh, MeshVertexBufferLayout},
|
||||||
render_asset::RenderAssets,
|
render_asset::RenderAssets,
|
||||||
@ -22,7 +22,8 @@ use bevy_transform::components::GlobalTransform;
|
|||||||
/// Component for rendering with meshes in the 2d pipeline, usually with a [2d material](crate::Material2d) such as [`ColorMaterial`](crate::ColorMaterial).
|
/// Component for rendering with meshes in the 2d pipeline, usually with a [2d material](crate::Material2d) such as [`ColorMaterial`](crate::ColorMaterial).
|
||||||
///
|
///
|
||||||
/// It wraps a [`Handle<Mesh>`] to differentiate from the 3d pipelines which use the handles directly as components
|
/// It wraps a [`Handle<Mesh>`] to differentiate from the 3d pipelines which use the handles directly as components
|
||||||
#[derive(Default, Clone, Component)]
|
#[derive(Default, Clone, Component, Debug, Reflect)]
|
||||||
|
#[reflect(Component)]
|
||||||
pub struct Mesh2dHandle(pub Handle<Mesh>);
|
pub struct Mesh2dHandle(pub Handle<Mesh>);
|
||||||
|
|
||||||
impl From<Handle<Mesh>> for Mesh2dHandle {
|
impl From<Handle<Mesh>> for Mesh2dHandle {
|
||||||
|
Loading…
Reference in New Issue
Block a user