Struct bevy::ecs::reflect::ReflectComponentFns
pub struct ReflectComponentFns {
pub from_world: fn(_: &mut World) -> Box<dyn Reflect, Global>,
pub insert: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static)),
pub apply: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static)),
pub apply_or_insert: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static)),
pub remove: fn(_: &mut EntityWorldMut<'_>),
pub contains: fn(_: EntityRef<'_>) -> bool,
pub reflect: fn(_: EntityRef<'_>) -> Option<&(dyn Reflect + 'static)>,
pub reflect_mut: fn(_: &'a mut EntityWorldMut<'_>) -> Option<Mut<'a, dyn Reflect>>,
pub reflect_unchecked_mut: unsafe fn(_: UnsafeEntityCell<'_>) -> Option<Mut<'_, dyn Reflect>>,
pub copy: fn(_: &World, _: &mut World, _: Entity, _: Entity),
}
Expand description
The raw function pointers needed to make up a ReflectComponent
.
This is used when creating custom implementations of ReflectComponent
with
ReflectComponent::new()
.
Note: Creating custom implementations of
ReflectComponent
is an advanced feature that most users will not need. Usually aReflectComponent
is created for a type by derivingReflect
and adding the#[reflect(Component)]
attribute. After adding the component to theTypeRegistry
, itsReflectComponent
can then be retrieved when needed.
Creating a custom ReflectComponent
may be useful if you need to create new component types
at runtime, for example, for scripting implementations.
By creating a custom ReflectComponent
and inserting it into a type’s
TypeRegistration
,
you can modify the way that reflected components of that type will be inserted into the Bevy
world.
Fields§
§from_world: fn(_: &mut World) -> Box<dyn Reflect, Global>
Function pointer implementing ReflectComponent::from_world()
.
insert: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static))
Function pointer implementing ReflectComponent::insert()
.
apply: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static))
Function pointer implementing ReflectComponent::apply()
.
apply_or_insert: fn(_: &mut EntityWorldMut<'_>, _: &(dyn Reflect + 'static))
Function pointer implementing ReflectComponent::apply_or_insert()
.
remove: fn(_: &mut EntityWorldMut<'_>)
Function pointer implementing ReflectComponent::remove()
.
contains: fn(_: EntityRef<'_>) -> bool
Function pointer implementing ReflectComponent::contains()
.
reflect: fn(_: EntityRef<'_>) -> Option<&(dyn Reflect + 'static)>
Function pointer implementing ReflectComponent::reflect()
.
reflect_mut: fn(_: &'a mut EntityWorldMut<'_>) -> Option<Mut<'a, dyn Reflect>>
Function pointer implementing ReflectComponent::reflect_mut()
.
reflect_unchecked_mut: unsafe fn(_: UnsafeEntityCell<'_>) -> Option<Mut<'_, dyn Reflect>>
Function pointer implementing ReflectComponent::reflect_unchecked_mut()
.
Safety
The function may only be called with an UnsafeEntityCell
that can be used to mutably access the relevant component on the given entity.
copy: fn(_: &World, _: &mut World, _: Entity, _: Entity)
Function pointer implementing ReflectComponent::copy()
.
Implementations§
§impl ReflectComponentFns
impl ReflectComponentFns
pub fn new<T>() -> ReflectComponentFnswhere
T: Component + Reflect + FromWorld,
pub fn new<T>() -> ReflectComponentFnswhere T: Component + Reflect + FromWorld,
Get the default set of ReflectComponentFns
for a specific component 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§
§impl Clone for ReflectComponentFns
impl Clone for ReflectComponentFns
§fn clone(&self) -> ReflectComponentFns
fn clone(&self) -> ReflectComponentFns
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for ReflectComponentFns
impl Send for ReflectComponentFns
impl Sync for ReflectComponentFns
impl Unpin for ReflectComponentFns
impl UnwindSafe for ReflectComponentFns
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§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.§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.