Game.Prefabs.UnlockOnBuildData
Assembly:
Assembly-CSharp (typical game assembly for mod/source code)
Namespace:
Game.Prefabs
Type:
struct
Base:
Unity.Entities.IBufferElementData
Summary:
A simple ECS buffer element that stores an Entity reference. Instances of this struct are intended to be stored in a DynamicBuffer on an entity (for example, a prefab) to represent other entities that should be "unlocked" or associated when the prefab is built/activated.
Fields
public Unity.Entities.Entity m_Entity
This field holds the Entity reference associated with this buffer element. In the context of "unlock on build", each entry typically points to an entity (such as a prefab or unlockable object) that should be made available when the owning building/prefab is constructed.
Properties
- This type has no properties.
As a plain IBufferElementData struct, it exposes only its public field(s) for direct storage in a DynamicBuffer.
Constructors
public UnlockOnBuildData()
Structs have an implicit parameterless constructor. By default m_Entity will be Entity.Null until explicitly assigned.
Methods
- This struct defines no methods.
It is a lightweight data container intended solely for storage inside an ECS DynamicBuffer.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// Adding/using the buffer on an entity (e.g. a prefab entity)
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity prefabEntity = /* obtain or create prefab entity */;
// Ensure the entity has a DynamicBuffer<UnlockOnBuildData>
if (!em.HasComponent<UnlockOnBuildData>(prefabEntity))
{
em.AddBuffer<UnlockOnBuildData>(prefabEntity);
}
DynamicBuffer<UnlockOnBuildData> unlockBuffer = em.GetBuffer<UnlockOnBuildData>(prefabEntity);
// Add an entry for an entity to be unlocked when this prefab is built
Entity toUnlock = /* some other entity */;
unlockBuffer.Add(new UnlockOnBuildData { m_Entity = toUnlock });
// In systems, read the buffer to process unlocks when a build event occurs