Game.Prefabs.OverlayElement
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: Unity.Entities.IBufferElementData
Summary:
A small ECS buffer element that holds a reference to an overlay Entity and an integer sort order. The struct is annotated with [InternalBufferCapacity(0)], meaning no inline storage is reserved on the entity; the buffer will be allocated externally. Use this element in a DynamicBuffer
Fields
-
public Unity.Entities.Entity m_Overlay
Reference to the overlay instance as an ECS Entity. This is the Entity representing the overlay/prefab to be rendered or otherwise processed by overlay systems. -
public int m_SortOrder
Integer used to control ordering of overlays within the buffer. The exact sort direction depends on the overlay rendering system (commonly, higher values render later/on-top). Use this to ensure overlays are processed/rendered in the intended order.
Properties
- (none)
This type is a plain data struct (buffer element) and exposes no C# properties.
Constructors
- (none defined)
This is a value type (struct). A default parameterless constructor is provided by C# and can be used to initialize fields, or construct instances using object initializer syntax.
Methods
- (none)
No methods are defined on this buffer element. It's intended purely as data carried in DynamicBuffer.
Usage Example
// Common usage in an ECS system: attach a DynamicBuffer<OverlayElement> to an entity
// and add overlay entries to it.
using Unity.Entities;
public void AddOverlayToEntity(EntityManager em, Entity parentEntity, Entity overlayEntity, int sortOrder)
{
// Ensure the entity has the buffer
if (!em.HasComponent<OverlayElement>(parentEntity))
{
em.AddBuffer<OverlayElement>(parentEntity);
}
var buffer = em.GetBuffer<OverlayElement>(parentEntity);
buffer.Add(new OverlayElement
{
m_Overlay = overlayEntity,
m_SortOrder = sortOrder
});
}
Notes: - Because this implements IBufferElementData, it's compatible with Unity's DynamicBuffer APIs and can be used in Jobs and Burst-compatible code paths when accessed correctly. - The [InternalBufferCapacity(0)] attribute indicates no inline storage on the entity; the buffer will be allocated with default/zero inline capacity.