Class Face
A face is composed of a set of triangles, and a material.
Triangle indices may point to the same vertex index as long as the vertices are unique to the face. That is, every vertex that a face references should only be used by that face's indices. To associate vertices that share common attributes (usually position), use the sharedVertices property.
ProBuilder automatically manages condensing common vertices in the Optimize(ProBuilderMesh, Boolean) function.
Inherited Members
Namespace: UnityEngine.ProBuilder
Syntax
[Serializable]
public sealed class Face
Constructors
Face()
Creates a Face with an empty triangles array.
Declaration
public Face()
Face(IEnumerable<Int32>)
Creates a face with default values and the specified set of triangles.
Declaration
public Face(IEnumerable<int> indices)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Int32> | indices | The new triangles array. |
Face(Face)
Creates a new Face as a copy of another face.
Declaration
public Face(Face other)
Parameters
Type | Name | Description |
---|---|---|
Face | other | The Face from which to copy properties and triangles. |
Properties
distinctIndexes
Gets a collection of the vertex indexes that the indexes array references, made distinct.
Declaration
public ReadOnlyCollection<int> distinctIndexes { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Int32> | A unique collection of vertices. |
edges
Gets the perimeter edges that compose this face.
Declaration
public ReadOnlyCollection<Edge> edges { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Edge> | The collection of edges on this face. |
indexes
Gets the triangle indices that compose this face.
Declaration
public ReadOnlyCollection<int> indexes { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Int32> | The array of indices representing this face's triangles. |
Item[Int32]
Gets the index for the specified triangle in this face's array of triangle indices.
Declaration
public int this[int i] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | i | The triangle to access |
Property Value
Type | Description |
---|---|
Int32 | The index of the specified triangle. |
manualUV
Gets or sets whether to map this face's UV coordinates manually or automatically. See Mapping Textures with UVs for an overview of the differences.
Declaration
public bool manualUV { get; set; }
Property Value
Type | Description |
---|---|
Boolean | True to set UV coordinates manually; false to use AutoUnwrapSettings. |
smoothingGroup
Gets or sets which smoothing group this face belongs to, if any. This is used to calculate vertex normals.
Declaration
public int smoothingGroup { get; set; }
Property Value
Type | Description |
---|---|
Int32 | The ID of this smoothing group as an integer. |
submeshIndex
Gets or sets the index of the submesh that this face belongs to.
Declaration
public int submeshIndex { get; set; }
Property Value
Type | Description |
---|---|
Int32 | The ID of the submesh as an integer. |
textureGroup
Gets or sets which texture group this face belongs to. ProBuilder uses texture groups when projecting Auto UVs. See Continuous tiling.
Declaration
public int textureGroup { get; set; }
Property Value
Type | Description |
---|---|
Int32 | ID of the texture group for this face. |
uv
Gets or sets a reference to the Auto UV mapping parameters.
Declaration
public AutoUnwrapSettings uv { get; set; }
Property Value
Type | Description |
---|---|
AutoUnwrapSettings | The ID of this submesh as an integer. |
Methods
Contains(Int32, Int32, Int32)
Tests whether a triangle matches one of the triangles of this face.
Declaration
public bool Contains(int a, int b, int c)
Parameters
Type | Name | Description |
---|---|---|
Int32 | a | First index in the triangle |
Int32 | b | Second index in the triangle |
Int32 | c | Third index in the triangle |
Returns
Type | Description |
---|---|
Boolean | True if {a,b,c} is found in this face's list of triangles; otherwise false. |
CopyFrom(Face)
Copies properties and triangles from the specified face to this face.
Declaration
public void CopyFrom(Face other)
Parameters
Type | Name | Description |
---|---|---|
Face | other | The Face from which to copy properties and triangles. |
IsQuad()
Returns whether this face can be converted to a quad (a polygon with four sides).
Declaration
public bool IsQuad()
Returns
Type | Description |
---|---|
Boolean | True if this face is divisible by 4; false otherwise. |
Reverse()
Reverses the order of the triangle array. This has the effect of reversing the direction that this face renders.
Declaration
public void Reverse()
SetIndexes(IEnumerable<Int32>)
Sets the triangles that compose this face.
Declaration
public void SetIndexes(IEnumerable<int> indices)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<Int32> | indices | The new triangle array. |
ShiftIndexes(Int32)
Adds an offset to each value in the indices array.
Declaration
public void ShiftIndexes(int offset)
Parameters
Type | Name | Description |
---|---|---|
Int32 | offset | The value to add to each index. |
ShiftIndexesToZero()
Finds the smallest value in the indices array, then offsets by subtracting that value from each index.
Declaration
public void ShiftIndexesToZero()
Examples
// sets the indexes array to `{0, 1, 2}`.
new Face(3,4,5).ShiftIndexesToZero();
ToQuad()
Converts a two-triangle face to a quad representation.
Declaration
public int[] ToQuad()
Returns
Type | Description |
---|---|
Int32[] | A quad (an array of four indices); or null if indices are not able to be represented as a quad. |
ToString()
Returns a string representation of the face.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | String formatted as |