Game.ArchetypeData
Assembly:
Assembly-CSharp (typical for game/mod code; not explicitly specified in the source file)
Namespace: Game.Prefabs
Type:
struct
Base:
System.ValueType (implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter)
Summary:
A small ECS component used to store an EntityArchetype reference on an entity. This struct is a plain value-type component (blittable) intended to carry an archetype descriptor so systems or other code can reuse or inspect a prefab-like archetype. Keep in mind EntityArchetype instances are tied to the EntityManager that created them and should not be assumed valid across different worlds or after that manager is destroyed.
Fields
public Unity.Entities.EntityArchetype m_Archetype
Holds a Unity.Entities.EntityArchetype value. Use this to refer to an archetype (a set of component types) that can be used for creating entities or comparisons. Because this is a raw archetype handle, ensure the associated EntityManager (or World) remains valid while using the value.
Properties
- None.
This struct defines no properties; it exposes a single public field for direct access.
Constructors
- No explicit constructors.
As a C# value type (struct), ArchetypeData uses the implicit default parameterless constructor which initializes m_Archetype to its default (an invalid/empty archetype handle). Initialize the field explicitly when creating instances.
Methods
- None.
This type only acts as a data container and does not define any methods.
Usage Example
using Unity.Entities;
// create or obtain an EntityManager (example uses the default world)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
// create an archetype describing the components your prefab needs
var prefabArchetype = entityManager.CreateArchetype(typeof(SomeComponent), typeof(SomeOtherComponent));
// create an entity and attach the ArchetypeData component to store the archetype handle
var entity = entityManager.CreateEntity();
entityManager.AddComponentData(entity, new Game.Prefabs.ArchetypeData { m_Archetype = prefabArchetype });
// later, a system can read ArchetypeData and use the stored archetype with the same EntityManager
Notes and best practices: - EntityArchetype values are specific to the EntityManager that created them. Do not use an archetype from one manager with a different manager or after the manager/world was disposed. - Because this is a public field on a struct component, it is blittable and suitable for use in jobs and entity queries, but manage ownership and lifetimes carefully to avoid invalid references.