Trait bevy_render::render_asset::RenderAsset

source ·
pub trait RenderAsset: Send + Sync + 'static + Sized {
    type SourceAsset: Asset + Clone;
    type Param: SystemParam;

    // Required method
    fn prepare_asset(
        source_asset: Self::SourceAsset,
        param: &mut SystemParamItem<'_, '_, Self::Param>
    ) -> Result<Self, PrepareAssetError<Self::SourceAsset>>;

    // Provided methods
    fn asset_usage(_source_asset: &Self::SourceAsset) -> RenderAssetUsages { ... }
    fn byte_len(source_asset: &Self::SourceAsset) -> Option<usize> { ... }
}
Expand description

Describes how an asset gets extracted and prepared for rendering.

In the ExtractSchedule step the RenderAsset::SourceAsset is transferred from the “main world” into the “render world”.

After that in the RenderSet::PrepareAssets step the extracted asset is transformed into its GPU-representation of type RenderAsset.

Required Associated Types§

source

type SourceAsset: Asset + Clone

The representation of the asset in the “main world”.

source

type Param: SystemParam

Specifies all ECS data required by RenderAsset::prepare_asset.

For convenience use the lifetimeless SystemParam.

Required Methods§

source

fn prepare_asset( source_asset: Self::SourceAsset, param: &mut SystemParamItem<'_, '_, Self::Param> ) -> Result<Self, PrepareAssetError<Self::SourceAsset>>

Prepares the RenderAsset::SourceAsset for the GPU by transforming it into a RenderAsset.

ECS data may be accessed via param.

Provided Methods§

source

fn asset_usage(_source_asset: &Self::SourceAsset) -> RenderAssetUsages

Whether or not to unload the asset after extracting it to the render world.

source

fn byte_len(source_asset: &Self::SourceAsset) -> Option<usize>

Size of the data the asset will upload to the gpu. Specifying a return value will allow the asset to be throttled via RenderAssetBytesPerFrame.

Object Safety§

This trait is not object safe.

Implementors§