Struct MaterialMeshInfo
Represents which materials and meshes to use to render an entity.
Implements
Namespace: Unity.Rendering
Assembly: Unity.Entities.Graphics.dll
Syntax
public struct MaterialMeshInfo : IComponentData, IQueryTypeParameter, IEnableableComponent
Remarks
This struct supports both a serializable static encoding in which case Material and Mesh are array indices to some array (typically a RenderMeshArray), and direct use of runtime BatchRendererGroup BatchMaterialID / BatchMeshID values.
Constructors
MaterialMeshInfo(BatchMaterialID, BatchMeshID, ushort)
Creates an instance of MaterialMeshInfo from material and mesh/sub-mesh IDs registered with Entities
Declaration
public MaterialMeshInfo(BatchMaterialID materialID, BatchMeshID meshID, ushort submeshIndex = 0)
Parameters
Type | Name | Description |
---|---|---|
Batch |
materialID | The material ID from Register |
Batch |
meshID | The mesh ID from Register |
ushort | submeshIndex | An optional submesh ID. |
Fields
Material
The material ID.
Declaration
public int Material
Field Value
Type | Description |
---|---|
int |
Remarks
The material ID can be one of the following:
- A literal Material ID received from the RegisterMaterial API, encoded as a positive integer.
- An array index to the RenderMeshArray shared component of the entity, encoded as a negative integer.
Use the literal Material ID to change the material at runtime. Use the array index to store the material ID to disk during entity baking.
Mesh
The mesh ID.
Declaration
public int Mesh
Field Value
Type | Description |
---|---|
int |
Properties
HasMaterialMeshIndexRange
True if the MaterialMeshInfo is using a MaterialMeshIndex range.
Declaration
public bool HasMaterialMeshIndexRange { get; }
Property Value
Type | Description |
---|---|
bool |
MaterialID
The material ID property.
Declaration
public BatchMaterialID MaterialID { get; set; }
Property Value
Type | Description |
---|---|
Batch |
MaterialMeshIndexRange
The MaterialMeshIndex range.
Declaration
public RangeInt MaterialMeshIndexRange { get; }
Property Value
Type | Description |
---|---|
Range |
MeshID
The mesh ID property.
Declaration
public BatchMeshID MeshID { get; set; }
Property Value
Type | Description |
---|---|
Batch |
SubMesh
The sub-mesh ID.
Declaration
public ushort SubMesh { get; set; }
Property Value
Type | Description |
---|---|
ushort |
Methods
ArrayIndexToStaticIndex(int)
Converts the given array index (typically the index inside RenderMeshArray) into a negative number that denotes that array position.
Declaration
public static int ArrayIndexToStaticIndex(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index to convert. |
Returns
Type | Description |
---|---|
int | Returns the converted index. |
FromMaterialMeshIndexRange(int, int)
Creates an instance of MaterialMeshInfo from a range of material/mesh/submesh index in the corresponding RenderMeshArray.
Declaration
public static MaterialMeshInfo FromMaterialMeshIndexRange(int rangeStart, int rangeLength)
Parameters
Type | Name | Description |
---|---|---|
int | rangeStart | The first index of the range in Material |
int | rangeLength | The length of the range in Material |
Returns
Type | Description |
---|---|
Material |
FromRenderMeshArrayIndices(int, int, ushort)
Creates an instance of MaterialMeshInfo from material and mesh/sub-mesh indices in the corresponding RenderMeshArray.
Declaration
public static MaterialMeshInfo FromRenderMeshArrayIndices(int materialIndexInRenderMeshArray, int meshIndexInRenderMeshArray, ushort submeshIndex = 0)
Parameters
Type | Name | Description |
---|---|---|
int | materialIndexInRenderMeshArray | The material index in Materials. |
int | meshIndexInRenderMeshArray | The mesh index in Meshes. |
ushort | submeshIndex | An optional submesh ID. |
Returns
Type | Description |
---|---|
Material |
Returns the MaterialMeshInfo instance that contains the material and mesh indices. |
StaticIndexToArrayIndex(int)
Converts the given static index (a negative value) to a valid array index.
Declaration
public static int StaticIndexToArrayIndex(int staticIndex)
Parameters
Type | Name | Description |
---|---|---|
int | staticIndex | The index to convert. |
Returns
Type | Description |
---|---|
int | Returns the converted index. |