Class AppendElements
Contains functions for appending elements to meshes.
Inherited Members
Namespace: UnityEngine.ProBuilder.MeshOperations
Syntax
public static class AppendElements
Methods
AppendFaces(ProBuilderMesh, Vector3[][], Color[][], Vector2[][], Face[], Int32[][])
Appends a group of new faces to the ProBuilderMesh.
Declaration
public static Face[] AppendFaces(this ProBuilderMesh mesh, Vector3[][] positions, Color[][] colors, Vector2[][] uvs, Face[] faces, int[][] shared)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh to append new faces to. |
Vector3[][] | positions | An array of position arrays, where the indices correspond to the |
Color[][] | colors | An array of colors arrays, where the indices correspond to the |
Vector2[][] | uvs | An array of UVs arrays, where the indices correspond to the |
Face[] | faces | An array of Face arrays, which contain the triangle winding information for each new face. Face index values are 0 indexed. |
Int32[][] | shared | An optional mapping of each new vertex's common index. Common index refers to a triangle's index in the sharedVertices array.
If you provide this value, include entries for each vertex position. For example, if there are four vertices in this face, there must be shared index entries for |
Returns
Type | Description |
---|---|
Face[] | An array of the new faces that this method successfully appended to the mesh; null if it failed. |
AppendVerticesToEdge(ProBuilderMesh, IList<Edge>, Int32)
Inserts a number of new points on each edge in the specified set of edges. Points are evenly spaced out along the edge.
Declaration
public static List<Edge> AppendVerticesToEdge(this ProBuilderMesh mesh, IList<Edge> edges, int count)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
IList<Edge> | edges | The edges to split with points. |
Int32 | count | The number of new points to insert. Must be greater than 0. |
Returns
Type | Description |
---|---|
List<Edge> | The new edges created by inserting points. |
AppendVerticesToEdge(ProBuilderMesh, Edge, Int32)
Inserts a number of new points on an edge. Points are evenly spaced out along the edge.
Declaration
public static List<Edge> AppendVerticesToEdge(this ProBuilderMesh mesh, Edge edge, int count)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
Edge | edge | The edge to split with points. |
Int32 | count | The number of new points to insert. Must be greater than 0. |
Returns
Type | Description |
---|---|
List<Edge> | The new edges created by inserting points. |
AppendVerticesToFace(ProBuilderMesh, Face, Vector3[])
Adds a set of points to a face and re-triangulates. Points are added to the nearest edge.
Declaration
public static Face AppendVerticesToFace(this ProBuilderMesh mesh, Face face, Vector3[] points)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
Face | face | The face to append points to. |
Vector3[] | points | Points to add to the face. |
Returns
Type | Description |
---|---|
Face | The face created by appending the points. |
AppendVerticesToFace(ProBuilderMesh, Face, Vector3[], Boolean)
Adds a set of points to a face and re-triangulates.
Declaration
public static Face AppendVerticesToFace(this ProBuilderMesh mesh, Face face, Vector3[] points, bool insertOnEdge)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
Face | face | The face to append points to. |
Vector3[] | points | Points to add to the face. |
Boolean | insertOnEdge | True to force new points to snap to edges. |
Returns
Type | Description |
---|---|
Face | The face created by appending the points. |
Bridge(ProBuilderMesh, Edge, Edge, Boolean)
Inserts a face between two edges.
This is the equivalent of the Bridge Edges action.
Declaration
public static Face Bridge(this ProBuilderMesh mesh, Edge a, Edge b, bool allowNonManifoldGeometry = false)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
Edge | a | First edge. |
Edge | b | Second edge |
Boolean | allowNonManifoldGeometry | If true, this function will allow edges to be bridged that create overlapping (non-manifold) faces. |
Returns
Type | Description |
---|---|
Face | The new face, or null of the action failed. |
CreatePolygon(ProBuilderMesh, IList<Int32>, Boolean)
Creates a new face that connects existing vertices.
Declaration
public static Face CreatePolygon(this ProBuilderMesh mesh, IList<int> indexes, bool unordered)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
IList<Int32> | indexes | The indices of the vertices to join with the new polygon. |
Boolean | unordered | False if the indices in an ordered path; true if not. For unordered indices, this function treats the polygon as a convex shape. ProBuilder allows concave shapes when triangulating ordered paths. |
Returns
Type | Description |
---|---|
Face | The new face that this action successfully created; null if action failed. |
CreatePolygonWithHole(ProBuilderMesh, IList<Int32>, IList<IList<Int32>>)
Creates a new face by connecting existing vertices.
Declaration
public static Face CreatePolygonWithHole(this ProBuilderMesh mesh, IList<int> indexes, IList<IList<int>> holes)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
IList<Int32> | indexes | The indexes of the vertices to join with the new polygon. |
IList<IList<Int32>> | holes | A list of indices defining holes. |
Returns
Type | Description |
---|---|
Face | The new face that this action successfully created; null if action failed. |
CreateShapeFromPolygon(PolyShape)
Creates a custom polygon shape from a set of points on a plane. The points must be ordered.
Declaration
public static ActionResult CreateShapeFromPolygon(this PolyShape poly)
Parameters
Type | Name | Description |
---|---|---|
PolyShape | poly | The PolyShape component to rebuild. |
Returns
Type | Description |
---|---|
ActionResult | An action result indicating the status of the operation. |
CreateShapeFromPolygon(ProBuilderMesh, IList<Vector3>, Single, Boolean)
Rebuilds a mesh from an ordered set of points.
Declaration
public static ActionResult CreateShapeFromPolygon(this ProBuilderMesh mesh, IList<Vector3> points, float extrude, bool flipNormals)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The target mesh. This method clears and repopulates the mesh values with the shape extruded from points. |
IList<Vector3> | points | A path of points to triangulate and extrude. |
Single | extrude | The distance to extrude. |
Boolean | flipNormals | True to invert the faces when creating the PolyShape. |
Returns
Type | Description |
---|---|
ActionResult | An ActionResult with the status of the operation. |
CreateShapeFromPolygon(ProBuilderMesh, IList<Vector3>, Single, Boolean, IList<IList<Vector3>>)
Rebuilds a mesh from an ordered set of points.
Declaration
public static ActionResult CreateShapeFromPolygon(this ProBuilderMesh mesh, IList<Vector3> points, float extrude, bool flipNormals, IList<IList<Vector3>> holePoints)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The target mesh. Clears and repopulates the mesh values with the shape extruded from points. |
IList<Vector3> | points | A path of points to triangulate and extrude. |
Single | extrude | The distance to extrude. |
Boolean | flipNormals | True to invert the faces when creating them. |
IList<IList<Vector3>> | holePoints | Holes in the polygon. Specify null if you want this method to ignore this value. |
Returns
Type | Description |
---|---|
ActionResult | An ActionResult with the status of the operation. |
DuplicateAndFlip(ProBuilderMesh, Face[])
Duplicates and reverses the winding direction for each face.
Declaration
public static void DuplicateAndFlip(this ProBuilderMesh mesh, Face[] faces)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The target mesh. |
Face[] | faces | The faces to duplicate, reverse triangle winding order, and append to mesh. |
InsertVertexInFace(ProBuilderMesh, Face, Vector3)
Adds a set of points to a face and retriangulates. Points are added to the nearest edge.
This is the equivalent of the Connect Vertices action.
Declaration
public static Face[] InsertVertexInFace(this ProBuilderMesh mesh, Face face, Vector3 point)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
Face | face | The face to append points to. |
Vector3 | point | Point to add to the face. |
Returns
Type | Description |
---|---|
Face[] | The face created by appending the points. |
InsertVertexInMesh(ProBuilderMesh, Vector3, Vector3)
Adds a point to a mesh.
Declaration
public static Vertex InsertVertexInMesh(this ProBuilderMesh mesh, Vector3 point, Vector3 normal)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
Vector3 | point | Point to add to the face. |
Vector3 | normal | The inserted point's normal. |
Returns
Type | Description |
---|---|
Vertex | The new inserted Vertex. |
InsertVertexOnEdge(ProBuilderMesh, Edge, Vector3)
Inserts a new point on an edge. Points are evenly spaced out along the edge.
This is the equivalent of the Subdivide Edges action.
Declaration
public static Vertex InsertVertexOnEdge(this ProBuilderMesh mesh, Edge originalEdge, Vector3 point)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
Edge | originalEdge | The edge to add the point to. |
Vector3 | point | The point to insert on the edge. |
Returns
Type | Description |
---|---|
Vertex | The new Vertex created. |