Class MeshUtility
Provides functions for generating mesh attributes and utilities.
Inherited Members
Namespace: UnityEngine.ProBuilder
Assembly: Unity.ProBuilder.dll
Syntax
public static class MeshUtility
Methods
CollapseSharedVertices(Mesh, Vertex[])
Merges coincident vertices where possible, optimizing the vertex count of a Mesh object.
Declaration
public static void CollapseSharedVertices(Mesh mesh, Vertex[] vertices = null)
Parameters
Type | Name | Description |
---|---|---|
Mesh | mesh | The mesh to optimize. |
Vertex[] | vertices | Specify an array of Vertex objects to use instead of extracting attributes from the mesh. This is a performance optimization for when this array already exists. If not specified, ProBuilder generates this array automatically. |
Compile(ProBuilderMesh, Mesh, MeshTopology)
Compiles a Mesh from a ProBuilderMesh.
Declaration
public static void Compile(ProBuilderMesh probuilderMesh, Mesh targetMesh, MeshTopology preferredTopology = MeshTopology.Triangles)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | probuilderMesh | The source mesh. |
Mesh | targetMesh | The destination |
MeshTopology | preferredTopology | True to try to create topology that matches the requested format. If the method can't create topology using the requested format, it uses triangles where necessary. |
CopyTo(Mesh, Mesh)
Copies mesh attribute values from one mesh to another.
Declaration
public static void CopyTo(Mesh source, Mesh destination)
Parameters
Type | Name | Description |
---|---|---|
Mesh | source | The mesh from which to copy attribute values. |
Mesh | destination | The destination mesh to copy attribute values to. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Throws if source or destination is null. |
DeepCopy(Mesh)
Returns a new mesh containing all attributes and values copied from the specified source mesh.
Declaration
public static Mesh DeepCopy(Mesh source)
Parameters
Type | Name | Description |
---|---|---|
Mesh | source | The mesh to copy from. |
Returns
Type | Description |
---|---|
Mesh | A new Mesh object with the same values as the source mesh. |
FitToSize(ProBuilderMesh, Bounds, Vector3)
Scales mesh vertices to fit within a bounding box.
Declaration
public static void FitToSize(ProBuilderMesh mesh, Bounds currentSize, Vector3 sizeToFit)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The mesh to scale. |
Bounds | currentSize | The bounding box that defines the mesh's shape. |
Vector3 | sizeToFit | The new size to fit mesh contents within. |
GenerateTangent(Mesh)
Generates tangents and applies them on the specified mesh.
Declaration
public static void GenerateTangent(Mesh mesh)
Parameters
Type | Name | Description |
---|---|---|
Mesh | mesh | The Mesh mesh target. |
GetIndexCount(Mesh)
Returns the number of indices 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 |
---|---|
uint | The count of all indices contained within this mesh's submeshes. |
GetPrimitiveCount(Mesh)
Returns the number of triangles or quads this mesh contains. No other mesh topologies are 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 |
---|---|
uint | The count of all triangles or quads contained within this mesh's submeshes. |
GetVertices(Mesh)
Creates a new array of vertices with values from a Mesh object.
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)
Prints a detailed string summary of the mesh attributes.
Declaration
public static string Print(Mesh mesh)
Parameters
Type | Name | Description |
---|---|---|
Mesh | mesh | The mesh to print information for. |
Returns
Type | Description |
---|---|
string | A tab-delimited string (positions, normals, colors, tangents, and UV coordinates). |