Skip to content

Commit

Permalink
#[reflect(Default)] for Handle/Mesh2dHandle (#12264)
Browse files Browse the repository at this point in the history
# Objective

- Make default handles constructible via reflection

## Solution

- Add missing `#[reflect(Default)]` to them

---------

Co-authored-by: Gino Valente <[email protected]>
  • Loading branch information
SludgePhD and MrGVSV authored Mar 4, 2024
1 parent 541a321 commit fadc6d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_asset/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
UntypedAssetId,
};
use bevy_ecs::prelude::*;
use bevy_reflect::{Reflect, TypePath};
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath};
use bevy_utils::{get_short_name, Uuid};
use crossbeam_channel::{Receiver, Sender};
use std::{
Expand Down Expand Up @@ -122,7 +122,7 @@ impl std::fmt::Debug for StrongHandle {
///
/// [`Handle::Strong`] also provides access to useful [`Asset`] metadata, such as the [`AssetPath`] (if it exists).
#[derive(Component, Reflect)]
#[reflect(Component)]
#[reflect(Default, Component, Debug, Hash, PartialEq)]
pub enum Handle<A: Asset> {
/// A "strong" reference to a live (or loading) [`Asset`]. If a [`Handle`] is [`Handle::Strong`], the [`Asset`] will be kept
/// alive until the [`Handle`] is dropped. Strong handles also provide access to additional asset metadata.
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_sprite/src/mesh2d/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_ecs::{
system::{lifetimeless::*, SystemParamItem, SystemState},
};
use bevy_math::{Affine3, Vec4};
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::mesh::MeshVertexBufferLayoutRef;
use bevy_render::{
batching::{
Expand Down Expand Up @@ -39,7 +39,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)]
#[reflect(Component)]
#[reflect(Default, Component)]
pub struct Mesh2dHandle(pub Handle<Mesh>);

impl From<Handle<Mesh>> for Mesh2dHandle {
Expand Down

0 comments on commit fadc6d0

Please sign in to comment.