Game.Prefabs.AreaData
Assembly: Game
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
AreaData is a lightweight ECS component used by the game's prefab/area systems to store an EntityArchetype reference associated with an area prefab. The component is a plain struct (blittable) and is marked for the game's custom serialization via IEmptySerializable. Typical usage is to keep the archetype that should be used when creating entities for a particular area or prefab spawning logic.
Fields
public Unity.Entities.EntityArchetype m_Archetype
Holds an EntityArchetype handle describing the component composition of entities that should be created for the area/prefab. The archetype is created through an EntityManager (e.g., CreateArchetype) and stored here so other systems can instantiate entities using that archetype.
Properties
- This struct does not expose any properties.
Constructors
implicit default constructor
As a struct there is no explicit constructor defined in the source; the default parameterless constructor will initialize m_Archetype to its default value.
Methods
- This struct defines no methods.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// Example: set up an area component that stores an archetype to use later when spawning entities
public void SetupArea(EntityManager entityManager, Entity areaEntity)
{
// Create an archetype composed of desired components for spawned entities
var spawnArchetype = entityManager.CreateArchetype(
typeof(Translation),
typeof(Rotation),
typeof(SomeSpawnableTag) // example component types
);
// Create and attach AreaData to an area entity so other systems can read which archetype to use
var areaData = new AreaData
{
m_Archetype = spawnArchetype
};
entityManager.AddComponentData(areaEntity, areaData);
}
// Later, a system can read AreaData.m_Archetype and use EntityManager.CreateEntity(archetype) to spawn.
Notes and tips: - EntityArchetype is a handle describing component composition; it is not an Entity and does not hold entity data. - Be careful when storing archetypes across worlds or different EntityManagers — archetypes are tied to the EntityManager that created them. - IEmptySerializable indicates the struct participates in the game's serialization pipeline; check the game's serialization conventions if you need custom persist/restore behavior.