Class MeshUtility
Functions for generating mesh attributes and various other mesh utilities.
Namespace: UnityEngine.ProBuilder
Syntax
public static class MeshUtility
Methods
CollapseSharedVertices(Mesh, Vertex[])
Merge coincident vertices where possible, optimizing the vertex count of a UnityEngine.Mesh.
Declaration
public static void CollapseSharedVertices(Mesh mesh, Vertex[] vertices = null)
Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | mesh | The mesh to optimize.  | 
| Vertex[] | vertices | If provided these values are used in place of extracting attributes from the Mesh.
  | 
Compile(ProBuilderMesh, Mesh, MeshTopology)
Compile a UnityEngine.Mesh from a ProBuilderMesh.
Declaration
public static void Compile(ProBuilderMesh probuilderMesh, Mesh targetMesh, MeshTopology preferredTopology = null)
Parameters
| Type | Name | Description | 
|---|---|---|
| ProBuilderMesh | probuilderMesh | The mesh source.  | 
| Mesh | targetMesh | Destination UnityEngine.Mesh.  | 
| MeshTopology | preferredTopology | If specified, the function will try to create topology matching the reqested format (and falling back on triangles where necessary).  | 
CopyTo(Mesh, Mesh)
Copy source mesh values to destination mesh.
Declaration
public static void CopyTo(Mesh source, Mesh destination)
Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | source | The mesh from which to copy attributes.  | 
| Mesh | destination | The destination mesh to copy attribute values to.  | 
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | Throws if source or destination is null.  | 
DeepCopy(Mesh)
Performs a deep copy of a mesh and returns a new mesh object.
Declaration
public static Mesh DeepCopy(Mesh source)
Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | source | The source mesh.  | 
Returns
| Type | Description | 
|---|---|
| Mesh | A new UnityEngine.Mesh object with the same values as source.  | 
GenerateTangent(Mesh)
Generate tangents and apply them.
Declaration
public static void GenerateTangent(Mesh mesh)
Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | mesh | The UnityEngine.Mesh mesh target.  | 
GetIndexCount(Mesh)
Get the number of indexes this mesh contains.
Declaration
public static uint GetIndexCount(Mesh mesh)
Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | mesh | The source mesh to sum submesh index counts from.  | 
Returns
| Type | Description | 
|---|---|
| UInt32 | The count of all indexes contained within this meshes submeshes.  | 
GetPrimitiveCount(Mesh)
Get the number of triangles or quads this mesh contains. Other mesh topologies are not considered.
Declaration
public static uint GetPrimitiveCount(Mesh mesh)
Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | mesh | The source mesh to sum submesh primitive counts from.  | 
Returns
| Type | Description | 
|---|---|
| UInt32 | The count of all triangles or quads contained within this meshes submeshes.  | 
GetVertices(Mesh)
Creates a new array of vertices with values from a UnityEngine.Mesh.
Declaration
public static Vertex[] GetVertices(this Mesh mesh)
Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | mesh | The source mesh.  | 
Returns
| Type | Description | 
|---|---|
| Vertex[] | An array of vertices.  | 
Print(Mesh)
Print a detailed string summary of the mesh attributes.
Declaration
public static string Print(Mesh mesh)
Parameters
| Type | Name | Description | 
|---|---|---|
| Mesh | mesh | 
Returns
| Type | Description | 
|---|---|
| String |