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 sharedIndexes property.
ProBuilder automatically manages condensing common vertices in the UnityEditor.ProBuilder.EditorMeshUtility.Optimize function.
Inherited Members
Namespace: UnityEngine.ProBuilder
Assembly: Unity.ProBuilder.dll
Syntax
[Serializable]
public sealed class Face
Constructors
Face()
Creates a Face with an empty triangles array.
Declaration
public Face()
Face(IEnumerable<int>)
Creates a face with default values and the specified set of triangles.
Declaration
public Face(IEnumerable<int> indices)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<int> | 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
this[int]
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 |
---|---|---|
int | i | The triangle to access |
Property Value
Type | Description |
---|---|
int | The index of the specified triangle. |
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<int> | 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<int> | The array of indices representing this face's triangles. |
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 |
---|---|
bool | 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 |
---|---|
int | 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 |
---|---|
int | 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 |
---|---|
int | 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(int, int, int)
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 |
---|---|---|
int | a | First index in the triangle |
int | b | Second index in the triangle |
int | c | Third index in the triangle |
Returns
Type | Description |
---|---|
bool | 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 |
---|---|
bool | 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<int>)
Sets the triangles that compose this face.
Declaration
public void SetIndexes(IEnumerable<int> indices)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<int> | indices | The new triangle array. |
ShiftIndexes(int)
Adds an offset to each value in the indices array.
Declaration
public void ShiftIndexes(int offset)
Parameters
Type | Name | Description |
---|---|---|
int | 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 |
---|---|
int[] | 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 |