Skip to content

Game.Rendering.MeshBatch

Assembly: Assembly-CSharp (game)
Namespace: Game.Rendering

Type: struct

Base: IBufferElementData, IEmptySerializable

Summary:
A small ECS buffer element that represents a mesh-batching mapping for a renderer. MeshBatch is stored in an entity DynamicBuffer and encodes indexes that tie an instance to a mesh group, mesh index and tile within the renderer's internal data. The struct is marked with InternalBufferCapacity(1), indicating the buffer is expected to commonly hold a single entry and should be optimized accordingly. IEmptySerializable is present to support the game's custom serialization path.


Fields

  • public int m_GroupIndex
    Index of the group this mesh batch belongs to. Typically used to look up per-group data structures in the renderer.

  • public int m_InstanceIndex
    Index of the instance within the renderer/instance pool. Used to identify which instance this batch corresponds to.

  • public byte m_MeshGroup
    Small index (0–255) identifying the mesh group within the batch. Use as an index into mesh-group tables.

  • public byte m_MeshIndex
    Small index (0–255) identifying the specific mesh inside the mesh group.

  • public byte m_TileIndex
    Small index (0–255) representing a tile (or sub-region) index for the mesh, if the renderer subdivides meshes into tiles.

Properties

  • public Unity.Jobs.JobHandle producerHandle { get; private set }
    No such property is defined on MeshBatch. (This template section is included for consistency; MeshBatch only defines the fields listed above.)

Constructors

  • public MeshBatch()
    MeshBatch has no custom constructors declared; the default parameterless constructor is used. Initialize fields as needed when creating instances.

Methods

  • None.
    MeshBatch is a plain data container (IBufferElementData) and does not define methods. All logic manipulating its values is expected to live in systems that operate on the DynamicBuffer.

Usage Example

// Example: adding a MeshBatch to an entity buffer in a system
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = /* obtain/create entity that owns mesh batches */;

var buffer = em.GetBuffer<MeshBatch>(entity);
buffer.Add(new MeshBatch {
    m_GroupIndex = 5,
    m_InstanceIndex = 42,
    m_MeshGroup = 1,
    m_MeshIndex = 3,
    m_TileIndex = 0
});

Additional notes: - InternalBufferCapacity(1) hints the runtime to pre-allocate space for one element in the entity's dynamic buffer; if you expect many MeshBatch entries per entity, the buffer will grow dynamically but with possible reallocation costs. - The byte fields limit indices to 0..255. If you need larger ranges, convert or rework index schemes accordingly.