docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    Face
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    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 [a, b, c], ....

    Overrides
    object.ToString()

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Constructors
      • Face()
      • Face(IEnumerable<int>)
      • Face(Face)
    • Properties
      • this[int]
      • distinctIndexes
      • edges
      • indexes
      • manualUV
      • smoothingGroup
      • submeshIndex
      • textureGroup
      • uv
    • Methods
      • Contains(int, int, int)
      • CopyFrom(Face)
      • IsQuad()
      • Reverse()
      • SetIndexes(IEnumerable<int>)
      • ShiftIndexes(int)
      • ShiftIndexesToZero()
      • ToQuad()
      • ToString()
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)