Trait amethyst_assets::PrefabData
source · pub trait PrefabData<'a> {
type SystemData: SystemData<'a>;
type Result;
fn add_to_entity(
&self,
entity: Entity,
system_data: &mut Self::SystemData,
entities: &[Entity]
) -> Result<Self::Result, PrefabError>;
fn load_sub_assets(
&mut self,
_progress: &mut ProgressCounter,
_system_data: &mut Self::SystemData
) -> Result<bool, PrefabError> { ... }
}
Expand description
Trait for loading a prefabs data for a single entity
Required Associated Types
sourcetype SystemData: SystemData<'a>
type SystemData: SystemData<'a>
SystemData
needed to perform the load
Required Methods
sourcefn add_to_entity(
&self,
entity: Entity,
system_data: &mut Self::SystemData,
entities: &[Entity]
) -> Result<Self::Result, PrefabError>
fn add_to_entity(
&self,
entity: Entity,
system_data: &mut Self::SystemData,
entities: &[Entity]
) -> Result<Self::Result, PrefabError>
Add the data for this prefab onto the given Entity
This can also be used to load resources, the recommended way of doing so is to put the
resources on the main Entity
of the Prefab
Parameters:
entity
:Entity
to load components on, or the rootEntity
for the resource scenariosystem_data
:SystemData
needed to do the loadingentities
: Some components need access to the entities that was created as part of the full prefab, for linking purposes, so this contains all thoseEntity
s.
Provided Methods
sourcefn load_sub_assets(
&mut self,
_progress: &mut ProgressCounter,
_system_data: &mut Self::SystemData
) -> Result<bool, PrefabError>
fn load_sub_assets(
&mut self,
_progress: &mut ProgressCounter,
_system_data: &mut Self::SystemData
) -> Result<bool, PrefabError>
Trigger asset loading for any sub assets.
Parameters:
progress
: Progress structure that needs to be used for tracking progress of sub loadssystem_data
:SystemData
for the prefab
Returns
Err(error)
- if anError
occursOk(false)
- if no sub assets need loadingOk(true)
- if sub assets need loading, in this case the sub asset load must be added to the given progress tracker
Type parameters:
P
: Progress tracker