Class Submesh
A set of indexes and material.
Inheritance
Namespace: UnityEngine.ProBuilder
Syntax
[Serializable]
public sealed class Submesh
Constructors
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. |
System.Int32 | subMeshIndex | Which submesh to read from. |
Submesh(Int32, MeshTopology, IEnumerable<Int32>)
Create new Submesh.
Declaration
public Submesh(int submeshIndex, MeshTopology topology, IEnumerable<int> indexes)
Parameters
Type | Name | Description |
---|---|---|
System.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. |
System.Collections.Generic.IEnumerable<System.Int32> | indexes | The triangles or quads. |
Properties
indexes
Declaration
public IEnumerable<int> indexes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.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 |
---|---|
System.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 = null)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.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. |
System.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 |
---|---|
System.NotImplementedException | Thrown in the event that a MeshTopology other than Quads or Triangles is passed. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |