pub struct ReflectResourceFns {
pub insert: fn(_: &mut World, _: &dyn Reflect, _: &TypeRegistry),
pub apply: fn(_: &mut World, _: &dyn Reflect),
pub apply_or_insert: fn(_: &mut World, _: &dyn Reflect, _: &TypeRegistry),
pub remove: fn(_: &mut World),
pub reflect: fn(_: &World) -> Option<&dyn Reflect>,
pub reflect_unchecked_mut: unsafe fn(_: UnsafeWorldCell<'_>) -> Option<Mut<'_, dyn Reflect>>,
pub copy: fn(_: &World, _: &mut World, _: &TypeRegistry),
}
bevy_reflect
only.Expand description
The raw function pointers needed to make up a ReflectResource
.
This is used when creating custom implementations of ReflectResource
with
ReflectResource::new()
.
Note: Creating custom implementations of
ReflectResource
is an advanced feature that most users will not need. Usually aReflectResource
is created for a type by derivingReflect
and adding the#[reflect(Resource)]
attribute. After adding the component to theTypeRegistry
, itsReflectResource
can then be retrieved when needed.
Creating a custom ReflectResource
may be useful if you need to create new resource types at
runtime, for example, for scripting implementations.
By creating a custom ReflectResource
and inserting it into a type’s
TypeRegistration
,
you can modify the way that reflected resources of that type will be inserted into the bevy
world.
Fields§
§insert: fn(_: &mut World, _: &dyn Reflect, _: &TypeRegistry)
Function pointer implementing ReflectResource::insert()
.
apply: fn(_: &mut World, _: &dyn Reflect)
Function pointer implementing ReflectResource::apply()
.
apply_or_insert: fn(_: &mut World, _: &dyn Reflect, _: &TypeRegistry)
Function pointer implementing ReflectResource::apply_or_insert()
.
remove: fn(_: &mut World)
Function pointer implementing ReflectResource::remove()
.
reflect: fn(_: &World) -> Option<&dyn Reflect>
Function pointer implementing ReflectResource::reflect()
.
reflect_unchecked_mut: unsafe fn(_: UnsafeWorldCell<'_>) -> Option<Mut<'_, dyn Reflect>>
Function pointer implementing ReflectResource::reflect_unchecked_mut()
.
§Safety
The function may only be called with an UnsafeWorldCell
that can be used to mutably access the relevant resource.
copy: fn(_: &World, _: &mut World, _: &TypeRegistry)
Function pointer implementing ReflectResource::copy()
.
Implementations§
Source§impl ReflectResourceFns
impl ReflectResourceFns
Sourcepub fn new<T: Resource + FromReflect>() -> Self
pub fn new<T: Resource + FromReflect>() -> Self
Get the default set of ReflectResourceFns
for a specific resource type using its
FromType
implementation.
This is useful if you want to start with the default implementation before overriding some of the functions to create a custom implementation.
Trait Implementations§
Source§impl Clone for ReflectResourceFns
impl Clone for ReflectResourceFns
Source§fn clone(&self) -> ReflectResourceFns
fn clone(&self) -> ReflectResourceFns
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ReflectResourceFns
impl RefUnwindSafe for ReflectResourceFns
impl Send for ReflectResourceFns
impl Sync for ReflectResourceFns
impl Unpin for ReflectResourceFns
impl UnwindSafe for ReflectResourceFns
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.