Class Face
A face is composed of a set of triangles, and a material.
Triangle indexes may point to the same vertex index as long as the vertices are unique to the face. Ie, 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 @"UnityEngine.ProBuilder.ProBuilderMesh.sharedIndexes" property.
ProBuilder automatically manages condensing common vertices in the EditorMeshUtility.Optimize function.
Namespace: UnityEngine.ProBuilder
Syntax
[Serializable]
public sealed class Face
Constructors
Face()
Default constructor creates a face with an empty triangles array.
Declaration
public Face()
Face(IEnumerable<Int32>)
Initialize a Face with a set of triangles and default values.
Declaration
public Face(IEnumerable<int> indices)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Int32> | indices | The new triangles array. |
Face(Face)
Deep copy constructor.
Declaration
public Face(Face other)
Parameters
Type | Name | Description |
---|---|---|
Face | other | The Face from which to copy properties. |
Properties
distinctIndexes
Declaration
public ReadOnlyCollection<int> distinctIndexes { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Int32> | A collection of the vertex indexes that the indexes array references, made distinct. |
edges
Declaration
public ReadOnlyCollection<Edge> edges { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Edge> | Get the perimeter edges that commpose this face. |
indexes
Declaration
public ReadOnlyCollection<int> indexes { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<Int32> | The triangle indexes that make up this face. |
Item[Int32]
Accesses the indexes array.
Declaration
public int this[int i] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | i |
Property Value
Type | Description |
---|---|
Int32 |
manualUV
Declaration
public bool manualUV { get; set; }
Property Value
Type | Description |
---|---|
Boolean | If this face has had it's UV coordinates done by hand, don't update them with the auto unwrap crowd. |
material
Declaration
[Obsolete("Face.material is deprecated. Please use submeshIndex instead.")]
public Material material { get; set; }
Property Value
Type | Description |
---|---|
Material | Get the material that face uses. |
smoothingGroup
Declaration
public int smoothingGroup { get; set; }
Property Value
Type | Description |
---|---|
Int32 | What smoothing group this face belongs to, if any. This is used to calculate vertex normals. |
submeshIndex
Declaration
public int submeshIndex { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
textureGroup
Declaration
public int textureGroup { get; set; }
Property Value
Type | Description |
---|---|
Int32 | What texture group this face belongs to. Used when projecting auto UVs. |
uv
Declaration
public AutoUnwrapSettings uv { get; set; }
Property Value
Type | Description |
---|---|
AutoUnwrapSettings | A reference to the Auto UV mapping parameters. |
Methods
Contains(Int32, Int32, Int32)
Test if a triangle is contained within the triangles array of this face.
Declaration
public bool Contains(int a, int b, int c)
Parameters
Type | Name | Description |
---|---|---|
Int32 | a | |
Int32 | b | |
Int32 | c |
Returns
Type | Description |
---|---|
Boolean |
CopyFrom(Face)
Copies values from other to this face.
Declaration
public void CopyFrom(Face other)
Parameters
Type | Name | Description |
---|---|---|
Face | other | The Face from which to copy properties. |
IsQuad()
Is this face representable as quad?
Declaration
public bool IsQuad()
Returns
Type | Description |
---|---|
Boolean |
Reverse()
Reverse 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>)
Set the triangles that compose this face.
Declaration
public void SetIndexes(IEnumerable<int> indices)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Int32> | indices | The new triangle array. |
ShiftIndexes(Int32)
Add offset to each value in the indexes 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 indexes 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()
Convert a 2 triangle face to a quad representation.
Declaration
public int[] ToQuad()
Returns
Type | Description |
---|---|
Int32[] | A quad (4 indexes), or null if indexes are not able to be represented as a quad. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |