Struct amethyst_assets::Prefab[][src]

pub struct Prefab<T> { /* fields omitted */ }

Main Prefab structure, containing all data loaded in a single prefab.

Contains a list prefab data for the entities affected by the prefab. The first entry in the entities list will be applied to the main Entity the Handle is placed on, and all other entries will trigger creation of a new entity. Note that the parent index is ignored for the first entry in the list.

The recommended way of loading resources is to place them on the main Entity.

Example:

If the prefab contains 3 new entities A, B and C, and the main Entity that the Handle is placed on is E, and we want the graph to be A -> E, B -> E, C -> B (parent links), the data will be as follows:

This example is not tested
Prefab {
    entities: vec![
        PrefabEntity { parent: None /* not used */, .. },
        PrefabEntity { parent: Some(0), .. },
        PrefabEntity { parent: Some(0), .. },
        PrefabEntity { parent: Some(2), .. },
    ],
}

Type parameters:

  • T: PrefabData

Methods

impl<T> Prefab<T>
[src]

Create new empty prefab

Create a prefab with data for only the main Entity

Set main Entity data

Add a new entity to the prefab, with optional data and parent.

Number of entities in the prefab, including the main entity

Create a new entity in the prefab, with no data and no parent

Get mutable access to the PrefabEntity with the given index

Get immutable access to all entities in the prefab

Important traits for &'a mut R

Get mutable access to the data in the PrefabEntity with the given index

If data is None, this will insert a default value for T

Panics

If the given index do not have a PrefabEntity

Check if sub asset loading have been triggered

Get the ProgressCounter for the sub asset loading.

Panics

If sub asset loading have not been triggered

Trigger sub asset loading for the asset

Trait Implementations

impl<T: Default> Default for Prefab<T>
[src]

Returns the "default value" for a type. Read more

impl<T> Asset for Prefab<T> where
    T: Send + Sync + 'static, 
[src]

NAME: &'static str = "PREFAB"

An identifier for this asset used for debugging.

The Data type the asset can be created from.

The ECS storage type to be used. You'll want to use VecStorage in most cases.

Auto Trait Implementations

impl<T> Send for Prefab<T> where
    T: Send

impl<T> Sync for Prefab<T> where
    T: Sync