Game.Prefabs.BatchGroup
Assembly:
Assembly-CSharp (typical for game/runtime code; may vary depending on build)
Namespace:
Game.Prefabs
Type:
struct
Base:
Unity.Entities.IBufferElementData
Summary:
Represents an element stored in an Entity buffer that groups rendering batches. Marked with InternalBufferCapacity(4) so small arrays of these elements are stored inline on the entity before spilling to heap memory. This struct holds indexing and classification information used by the rendering/mesh batching systems: a group index, a merge index, the mesh layer and type, and a partition id.
Fields
-
public int m_GroupIndex
Identifier for the batch group. Used to group meshes that can be rendered/processed together. -
public int m_MergeIndex
Index used for merge operations (e.g., meshes merged into a single draw). Distinguishes merge sets inside a group. -
public MeshLayer m_Layer
Enum-like value indicating the rendering layer for the mesh (opaque, transparent, overlay, etc.). Determines ordering and which render pass or layer the mesh belongs to. -
public MeshType m_Type
Enum-like value indicating the specific mesh type/category (terrain, building, props, vegetation, etc.). Used by batching and processing logic to handle different mesh kinds. -
public ushort m_Partition
Small integer partition id — used to subdivide or partition batches (for thread/job assignment, GPU partitioning, or submesh indexing). Stored as ushort to save space in the buffer element.
Note: The exact definitions of MeshLayer and MeshType are defined elsewhere in the codebase; they are typically enums or small integer types used by the rendering pipeline.
Properties
- None (this is a plain public-field struct used as an IBufferElementData).
Constructors
public BatchGroup()
(implicit default)
As a value type (struct), BatchGroup has the implicit default constructor that zero-initializes all fields. No explicit constructor is defined in the source.
Methods
- None (no methods are defined on this struct).
Usage Example
// Example showing how to add and use a BatchGroup buffer on an entity
using Unity.Entities;
using Game.Prefabs;
// assume entityManager and entity are available
var buffer = entityManager.AddBuffer<BatchGroup>(entity);
// add a batch group entry
buffer.Add(new BatchGroup {
m_GroupIndex = 5,
m_MergeIndex = 1,
m_Layer = MeshLayer.Opaque, // example enum value
m_Type = MeshType.Building, // example enum value
m_Partition = 0
});
// Or within a system:
Entities
.WithAll<SomeRenderableTag>()
.ForEach((Entity e, DynamicBuffer<BatchGroup> groups) => {
groups.Add(new BatchGroup {
m_GroupIndex = 2,
m_MergeIndex = 0,
m_Layer = MeshLayer.Transparent,
m_Type = MeshType.Prop,
m_Partition = 1
});
}).Schedule();
Notes and tips: - The [InternalBufferCapacity(4)] attribute means small buffers (up to 4 items) are stored inline with the entity, reducing allocations. If you expect more elements frequently, be aware that larger buffers will allocate on the heap. - This struct is meant to be cheap and POD-like so it can be used in jobs and component buffers without managed allocations. - Check the definitions of MeshLayer and MeshType in the codebase to use valid enum values and understand render ordering/semantics.