Skip to content

Game.Prefabs.UIGroupElement

Assembly: Game
Namespace: Game.Prefabs

Type: struct

Base: Unity.Entities.IBufferElementData

Summary:
A lightweight buffer element that holds a reference to a UI prefab Entity. Marked with [InternalBufferCapacity(0)] so the dynamic buffer has no inline storage and elements are stored in the chunks' external buffer storage. Use this element in a DynamicBuffer to associate one or more UI prefab Entities with an entity (for example, a UI group or container entity).


Fields

  • public Unity.Entities.Entity m_Prefab
    Holds the Entity that represents the UI prefab. This field is public and can be read or written when working with the DynamicBuffer.

Properties

  • This type defines no properties. It is a simple IBufferElementData struct with a single public field.

Constructors

  • public UIGroupElement(Unity.Entities.Entity prefab)
    Initializes a new UIGroupElement with the provided prefab Entity.

Methods

  • This type defines no methods. It is intended to be used as a plain buffer element with DynamicBuffer.

Usage Example

// Obtain EntityManager (in a SystemBase you can use EntityManager directly)
var em = World.DefaultGameObjectInjectionWorld.EntityManager;

// Assume 'containerEntity' is an entity representing some UI group/container,
// and 'prefabEntity' is an Entity reference to a UI prefab.
var buffer = em.GetBuffer<Game.Prefabs.UIGroupElement>(containerEntity);
buffer.Add(new Game.Prefabs.UIGroupElement(prefabEntity));

// Or when creating an entity, add buffer elements:
var archetype = em.CreateArchetype(typeof(Game.Prefabs.UIGroupElement));
var entity = em.CreateEntity(archetype);
var buf = em.GetBuffer<Game.Prefabs.UIGroupElement>(entity);
buf.Add(new Game.Prefabs.UIGroupElement(prefabEntity));