Game.Prefabs.MeshMaterial
Assembly: Game
Namespace: Game.Prefabs
Type: struct
Base: Unity.Entities.IBufferElementData
Summary:
Represents a single sub-mesh / material range for a mesh. Instances describe ranges of indices and vertices and which material index to use. Intended to be stored in a DynamicBuffer on an entity (ECS) so that mesh geometry can reference multiple material sub-ranges. The struct is annotated with [InternalBufferCapacity(0)], meaning no inline capacity is reserved and the buffer will allocate storage externally when used.
Fields
-
public int m_StartIndex
Start index in the mesh index buffer where this sub-mesh begins. -
public int m_IndexCount
Number of indices that belong to this sub-mesh. -
public int m_StartVertex
Start vertex index in the mesh vertex buffer for this sub-mesh. -
public int m_VertexCount
Number of vertices that belong to this sub-mesh. -
public int m_MaterialIndex
Index of the material to use for this sub-mesh (typically an index into a materials array).
Properties
- This struct exposes no properties; it uses plain public fields for data storage.
Constructors
public MeshMaterial(int startIndex, int indexCount, int startVertex, int vertexCount, int materialIndex)
Creates a MeshMaterial describing the index/vertex ranges and material index.- startIndex: first index in the index buffer
- indexCount: number of indices for the sub-mesh
- startVertex: first vertex in the vertex buffer
- vertexCount: number of vertices for the sub-mesh
- materialIndex: material slot/index to apply
Methods
- This struct defines no methods beyond the compiler-provided value-type methods. It is a plain data container used with Unity.Entities.DynamicBuffer
.
Usage Example
// Add and populate a DynamicBuffer<MeshMaterial> on an entity
var buffer = entityManager.AddBuffer<MeshMaterial>(entity);
// Add a sub-mesh that starts at index 0, uses 36 indices, starts at vertex 0, has 24 vertices, and uses material slot 1
buffer.Add(new MeshMaterial(0, 36, 0, 24, 1));
// Multiple entries allow representing a mesh with multiple materials/sub-meshes
buffer.Add(new MeshMaterial(36, 30, 24, 20, 2));