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§
Sourcetype SourceAsset: Asset + Clone
type SourceAsset: Asset + Clone
The representation of the asset in the “main world”.
Sourcetype Param: SystemParam
type Param: SystemParam
Specifies all ECS data required by RenderAsset::prepare_asset.
For convenience use the lifetimeless SystemParam.
Required Methods§
Sourcefn prepare_asset(
source_asset: Self::SourceAsset,
param: &mut SystemParamItem<'_, '_, Self::Param>,
) -> Result<Self, PrepareAssetError<Self::SourceAsset>>
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§
Sourcefn asset_usage(_source_asset: &Self::SourceAsset) -> RenderAssetUsages
fn asset_usage(_source_asset: &Self::SourceAsset) -> RenderAssetUsages
Whether or not to unload the asset after extracting it to the render world.
Sourcefn byte_len(source_asset: &Self::SourceAsset) -> Option<usize>
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.
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.