Skip to main content

ExtractComponent

Trait ExtractComponent 

Source
pub trait ExtractComponent<F = ()>: SyncComponent<F> {
    type QueryData: ReadOnlyQueryData;
    type QueryFilter: QueryFilter;
    type Out: Bundle<Effect: NoBundleEffect>;

    // Required method
    fn extract_component(
        item: QueryItem<'_, '_, Self::QueryData>,
    ) -> Option<Self::Out>;
}
Expand description

Describes how a component gets extracted for rendering.

Therefore the component is transferred from the “app world” into the “render world” in the ExtractSchedule step. This functionality is enabled by adding ExtractComponentPlugin with the component type.

The Out type is defined in SyncComponent.

The marker type F is only used as a way to bypass the orphan rules. To implement the trait for a foreign type you can use a local type as the marker, e.g. the type of the plugin that calls ExtractComponentPlugin.

Required Associated Types§

Source

type QueryData: ReadOnlyQueryData

ECS ReadOnlyQueryData to fetch the components to extract.

Source

type QueryFilter: QueryFilter

Filters the entities with additional constraints.

Source

type Out: Bundle<Effect: NoBundleEffect>

The output from extraction, i.e. ExtractComponent::extract_component.

The output components won’t be removed automatically from the render world if the implementing component is removed, unless you set them in the SyncComponent::Target.

Required Methods§

Source

fn extract_component( item: QueryItem<'_, '_, Self::QueryData>, ) -> Option<Self::Out>

Defines how the component is transferred into the “render world”.

Returning None based on the queried item will remove the SyncComponent::Target from the entity in the render world.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ExtractComponent for CameraMainTextureUsages

Source§

impl ExtractComponent for Camera2d

Source§

impl ExtractComponent for Camera3d

Implementors§