Game.Rendering.MeshGroup
Assembly: Assembly-CSharp (game code)
Namespace: Game.Rendering
Type: public struct MeshGroup
Base: System.ValueType, Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.IEmptySerializable
Summary:
Represents a lightweight buffer element used by the rendering pipeline to reference a sub-mesh group and small offsets into mesh and color data. The struct is marked with InternalBufferCapacity(1) to optimize storage for entities that typically store a single MeshGroup inline. It is a blittable value type (4 bytes: ushort + 1 byte + 1 byte) suitable for use in Unity ECS DynamicBuffer
Fields
-
public ushort m_SubMeshGroup
Identifier for the sub-mesh group. Typically indexes a sub-mesh grouping table or indicates which submesh set to render. Range 0–65535. -
public byte m_MeshOffset
Small offset (0–255) used by the renderer to index into per-mesh instance data (for example: an offset into a contiguous mesh data block or an index into a per-instance array). -
public byte m_ColorOffset
Small offset (0–255) used to index into per-instance color or material parameter arrays.
Notes:
- Total size is 4 bytes (2 + 1 + 1). The compact layout is intentional for memory and cache efficiency when stored in DynamicBuffer
Properties
- None. This struct exposes only public fields and does not define properties.
Constructors
public MeshGroup()
(implicit default)
The struct uses the default value-type constructor. All fields default to zero (m_SubMeshGroup = 0, m_MeshOffset = 0, m_ColorOffset = 0). There is no explicit constructor defined in the source.
Methods
- None. No methods are defined on this struct.
Usage Example
// Assume this system has access to an Entity with a DynamicBuffer<MeshGroup>
using Unity.Entities;
using Game.Rendering;
public partial struct ExampleSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
// Example: add a MeshGroup entry to an entity's buffer
Entity e = /* obtain entity */;
if (state.EntityManager.HasComponent<MeshGroup>(e))
{
var buffer = state.EntityManager.GetBuffer<MeshGroup>(e);
var mg = new MeshGroup
{
m_SubMeshGroup = 2,
m_MeshOffset = 5,
m_ColorOffset = 1
};
buffer.Add(mg);
}
}
}
Additional notes:
- Because MeshGroup implements IBufferElementData, use it with DynamicBuffer