Class Submesh
A set of indexes and material.
Namespace: UnityEngine.ProBuilder
Syntax
[Serializable]
public sealed class Submesh
Constructors
Submesh(Int32, MeshTopology, IEnumerable<Int32>)
Create new Submesh.
Declaration
public Submesh(int submeshIndex, MeshTopology topology, IEnumerable<int> indexes)
Parameters
Type | Name | Description |
---|---|---|
Int32 | submeshIndex | The index of this submesh corresponding to the MeshRenderer.sharedMaterials property. |
MeshTopology | topology | What topology is this submesh. ProBuilder only recognizes Triangles and Quads. |
IEnumerable<Int32> | indexes | The triangles or quads. |
Submesh(Mesh, Int32)
Create new Submesh from a mesh, submesh index, and material.
Declaration
public Submesh(Mesh mesh, int subMeshIndex)
Parameters
Type | Name | Description |
---|---|---|
Mesh | mesh | The source mesh. |
Int32 | subMeshIndex | Which submesh to read from. |
Properties
indexes
Declaration
public IEnumerable<int> indexes { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<Int32> | Indexes making up this submesh. Can be triangles or quads, check with topology. |
submeshIndex
Declaration
public int submeshIndex { get; set; }
Property Value
Type | Description |
---|---|
Int32 | The index in the sharedMaterials array that this submesh aligns with. |
topology
Declaration
public MeshTopology topology { get; set; }
Property Value
Type | Description |
---|---|
MeshTopology | What is the topology (triangles, quads) of this submesh? |
Methods
GetSubmeshes(IEnumerable<Face>, Int32, MeshTopology)
Create submeshes from a set of faces. Currently only Quads and Triangles are supported.
Declaration
public static Submesh[] GetSubmeshes(IEnumerable<Face> faces, int submeshCount, MeshTopology preferredTopology = MeshTopology.Triangles)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Face> | faces | The faces to be included in the resulting submeshes. This method handles groups submeshes by comparing the material property of each face. |
Int32 | submeshCount | How many submeshes to create. Usually you will just want to pass the length of the MeshRenderer.sharedMaterials array. |
MeshTopology | preferredTopology | Should the resulting submeshes be in quads or triangles. Note that quads are not guaranteed; ie, some faces may not be able to be represented in quad format and will fall back on triangles. |
Returns
Type | Description |
---|---|
Submesh[] | An array of Submeshes. |
Exceptions
Type | Condition |
---|---|
NotImplementedException | Thrown in the event that a MeshTopology other than Quads or Triangles is passed. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |