Class Vertex | ProBuilder | 4.3.1
docs.unity3d.com
    Show / Hide Table of Contents

    Class Vertex

    Holds information about a single vertex, and provides methods for averaging between many. All values are optional. Where not present a default value will be substituted if necessary.

    Inheritance
    Object
    Vertex
    Namespace: UnityEngine.ProBuilder
    Syntax
    [Serializable]
    public sealed class Vertex : IEquatable<Vertex>

    Constructors

    Vertex()

    Initialize a Vertex with no values.

    Declaration
    public Vertex()

    Vertex(Vertex)

    Copy constructor.

    Declaration
    public Vertex(Vertex vertex)
    Parameters
    Type Name Description
    Vertex vertex

    The Vertex to copy field data from.

    Properties

    color

    Declaration
    public Color color { get; set; }
    Property Value
    Type Description
    Color

    Vertex color.

    See Also
    colors

    normal

    Declaration
    public Vector3 normal { get; set; }
    Property Value
    Type Description
    Vector3

    Unit vector normal.

    See Also
    GetNormals()

    position

    Declaration
    public Vector3 position { get; set; }
    Property Value
    Type Description
    Vector3

    The position in model space.

    See Also
    positions

    tangent

    Declaration
    public Vector4 tangent { get; set; }
    Property Value
    Type Description
    Vector4

    Vertex tangent (sometimes called binormal).

    See Also
    tangents

    uv0

    Declaration
    public Vector2 uv0 { get; set; }
    Property Value
    Type Description
    Vector2

    UV 0 channel. Also called textures.

    See Also
    textures
    GetUVs(Int32, List<Vector4>)

    uv2

    Declaration
    public Vector2 uv2 { get; set; }
    Property Value
    Type Description
    Vector2

    UV 2 channel.

    See Also
    GetUVs(Int32, List<Vector4>)

    uv3

    Declaration
    public Vector4 uv3 { get; set; }
    Property Value
    Type Description
    Vector4

    UV 3 channel.

    See Also
    GetUVs(Int32, List<Vector4>)

    uv4

    Declaration
    public Vector4 uv4 { get; set; }
    Property Value
    Type Description
    Vector4

    UV 4 channel.

    See Also
    GetUVs(Int32, List<Vector4>)

    Methods

    Add(Vertex)

    Addition is performed component-wise for every property.

    Declaration
    public void Add(Vertex b)
    Parameters
    Type Name Description
    Vertex b

    Right side addition parameter.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Add(Vertex, Vertex)

    Addition is performed component-wise for every property.

    Declaration
    public static Vertex Add(Vertex a, Vertex b)
    Parameters
    Type Name Description
    Vertex a

    Left side addition parameter.

    Vertex b

    Right side addition parameter.

    Returns
    Type Description
    Vertex

    A new Vertex with the sum of a + b.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Average(IList<Vertex>, IList<Int32>)

    Average all vertices to a single vertex.

    Declaration
    public static Vertex Average(IList<Vertex> vertices, IList<int> indexes = null)
    Parameters
    Type Name Description
    IList<Vertex> vertices

    A list of vertices.

    IList<Int32> indexes

    If indexes is null, all vertices will be averaged. If indexes is provided, only the vertices referenced by the indexes array are averaged.

    Returns
    Type Description
    Vertex

    An averaged vertex value.

    Divide(Single)

    Division is performed component-wise for every property.

    Declaration
    public void Divide(float value)
    Parameters
    Type Name Description
    Single value

    Right side Division parameter.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Divide(Vertex, Single)

    Division is performed component-wise for every property.

    Declaration
    public static Vertex Divide(Vertex a, float value)
    Parameters
    Type Name Description
    Vertex a

    Left side division parameter.

    Single value

    Right side division parameter.

    Returns
    Type Description
    Vertex

    A new Vertex with the sum of a / b.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Equals(Object)

    Compare Vertex to an object.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    The object to compare this vertex to.

    Returns
    Type Description
    Boolean

    True if obj is a Vertex, and equal to this.

    Overrides
    Object.Equals(Object)

    Equals(Vertex)

    Compare the equality of vertex values. Uses the @"UnityEngine.ProBuilder.Math" Approx functions to compare float values.

    Declaration
    public bool Equals(Vertex other)
    Parameters
    Type Name Description
    Vertex other

    The vertex to compare.

    Returns
    Type Description
    Boolean

    True if all values are the same (within float.Epsilon).

    Equals(Vertex, MeshArrays)

    Declaration
    public bool Equals(Vertex other, MeshArrays mask)
    Parameters
    Type Name Description
    Vertex other
    MeshArrays mask
    Returns
    Type Description
    Boolean

    GetArrays(IList<Vertex>, out Vector3[], out Color[], out Vector2[], out Vector3[], out Vector4[], out Vector2[], out List<Vector4>, out List<Vector4>)

    Allocate and fill all attribute arrays. This method will fill all arrays, regardless of whether or not real data populates the values (check what attributes a Vertex contains with HasAttribute()).

    Declaration
    public static void GetArrays(IList<Vertex> vertices, out Vector3[] position, out Color[] color, out Vector2[] uv0, out Vector3[] normal, out Vector4[] tangent, out Vector2[] uv2, out List<Vector4> uv3, out List<Vector4> uv4)
    Parameters
    Type Name Description
    IList<Vertex> vertices

    The source vertices.

    Vector3[] position

    A new array of the vertex position values.

    Color[] color

    A new array of the vertex color values.

    Vector2[] uv0

    A new array of the vertex uv0 values.

    Vector3[] normal

    A new array of the vertex normal values.

    Vector4[] tangent

    A new array of the vertex tangent values.

    Vector2[] uv2

    A new array of the vertex uv2 values.

    List<Vector4> uv3

    A new array of the vertex uv3 values.

    List<Vector4> uv4

    A new array of the vertex uv4 values.

    Remarks

    If you are using this function to rebuild a mesh, use SetMesh instead. SetMesh handles setting null arrays where appropriate for you.

    See Also
    SetMesh(Mesh, IList<Vertex>)

    GetArrays(IList<Vertex>, out Vector3[], out Color[], out Vector2[], out Vector3[], out Vector4[], out Vector2[], out List<Vector4>, out List<Vector4>, MeshArrays)

    Allocate and fill the requested attribute arrays.

    Declaration
    public static void GetArrays(IList<Vertex> vertices, out Vector3[] position, out Color[] color, out Vector2[] uv0, out Vector3[] normal, out Vector4[] tangent, out Vector2[] uv2, out List<Vector4> uv3, out List<Vector4> uv4, MeshArrays attributes)
    Parameters
    Type Name Description
    IList<Vertex> vertices

    The source vertices.

    Vector3[] position

    A new array of the vertex position values if requested by the attributes parameter, or null.

    Color[] color

    A new array of the vertex color values if requested by the attributes parameter, or null.

    Vector2[] uv0

    A new array of the vertex uv0 values if requested by the attributes parameter, or null.

    Vector3[] normal

    A new array of the vertex normal values if requested by the attributes parameter, or null.

    Vector4[] tangent

    A new array of the vertex tangent values if requested by the attributes parameter, or null.

    Vector2[] uv2

    A new array of the vertex uv2 values if requested by the attributes parameter, or null.

    List<Vector4> uv3

    A new array of the vertex uv3 values if requested by the attributes parameter, or null.

    List<Vector4> uv4

    A new array of the vertex uv4 values if requested by the attributes parameter, or null.

    MeshArrays attributes

    A flag with the MeshAttributes requested.

    Remarks

    If you are using this function to rebuild a mesh, use SetMesh instead. SetMesh handles setting null arrays where appropriate for you.

    See Also
    SetMesh(Mesh, IList<Vertex>)
    HasArrays(MeshArrays)

    GetHashCode()

    Creates a new hashcode from position, uv0, and normal.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    A hashcode for this object.

    Overrides
    Object.GetHashCode()

    HasArrays(MeshArrays)

    Find if a vertex attribute has been set.

    Declaration
    public bool HasArrays(MeshArrays attribute)
    Parameters
    Type Name Description
    MeshArrays attribute

    The attribute or attributes to test for.

    Returns
    Type Description
    Boolean

    True if this vertex has the specified attributes set, false if they are default values.

    Mix(Vertex, Vertex, Single)

    Linearly interpolate between two vertices.

    Declaration
    public static Vertex Mix(Vertex x, Vertex y, float weight)
    Parameters
    Type Name Description
    Vertex x

    Left parameter.

    Vertex y

    Right parameter.

    Single weight

    The weight of the interpolation. 0 is fully x, 1 is fully y.

    Returns
    Type Description
    Vertex

    A new vertex interpolated by weight between x and y.

    Multiply(Single)

    Multiplication is performed component-wise for every property.

    Declaration
    public void Multiply(float value)
    Parameters
    Type Name Description
    Single value

    Right side multiplication parameter.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Multiply(Vertex, Single)

    Multiplication is performed component-wise for every property.

    Declaration
    public static Vertex Multiply(Vertex a, float value)
    Parameters
    Type Name Description
    Vertex a

    Left side multiplication parameter.

    Single value

    Right side multiplication parameter.

    Returns
    Type Description
    Vertex

    A new Vertex with the sum of a * b.

    Normalize()

    Normalize all vector values in place.

    Declaration
    public void Normalize()

    SetMesh(Mesh, IList<Vertex>)

    Replace mesh values with vertex array. Mesh is cleared during this function, so be sure to set the triangles after calling.

    Declaration
    public static void SetMesh(Mesh mesh, IList<Vertex> vertices)
    Parameters
    Type Name Description
    Mesh mesh

    The target mesh.

    IList<Vertex> vertices

    The vertices to replace the mesh attributes with.

    Subtract(Vertex)

    Subtraction is performed component-wise for every property.

    Declaration
    public void Subtract(Vertex b)
    Parameters
    Type Name Description
    Vertex b

    Right side subtraction parameter.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Subtract(Vertex, Vertex)

    Subtraction is performed component-wise for every property.

    Declaration
    public static Vertex Subtract(Vertex a, Vertex b)
    Parameters
    Type Name Description
    Vertex a

    Left side subtraction parameter.

    Vertex b

    Right side subtraction parameter.

    Returns
    Type Description
    Vertex

    A new Vertex with the sum of a - b.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    ToString(String)

    ToString override that prints every available property.

    Declaration
    public string ToString(string args = null)
    Parameters
    Type Name Description
    String args

    An optional string argument that is provided to the component ToString calls.

    Returns
    Type Description
    String

    A string with the values of all set properties.

    Operators

    Addition(Vertex, Vertex)

    Addition is performed component-wise for every property.

    Declaration
    public static Vertex operator +(Vertex a, Vertex b)
    Parameters
    Type Name Description
    Vertex a

    Left side addition parameter.

    Vertex b

    Right side addition parameter.

    Returns
    Type Description
    Vertex

    A new Vertex with the sum of a + b.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Division(Vertex, Single)

    Division is performed component-wise for every property.

    Declaration
    public static Vertex operator /(Vertex a, float value)
    Parameters
    Type Name Description
    Vertex a

    Left side division parameter.

    Single value

    Right side division parameter.

    Returns
    Type Description
    Vertex

    A new Vertex with the sum of a / b.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Equality(Vertex, Vertex)

    Declaration
    public static bool operator ==(Vertex a, Vertex b)
    Parameters
    Type Name Description
    Vertex a
    Vertex b
    Returns
    Type Description
    Boolean

    Inequality(Vertex, Vertex)

    Test for inequality.

    Declaration
    public static bool operator !=(Vertex a, Vertex b)
    Parameters
    Type Name Description
    Vertex a

    Left parameter.

    Vertex b

    Right parameter.

    Returns
    Type Description
    Boolean

    True if a does not equal b.

    Multiply(Vertex, Single)

    Multiplication is performed component-wise for every property.

    Declaration
    public static Vertex operator *(Vertex a, float value)
    Parameters
    Type Name Description
    Vertex a

    Left side multiplication parameter.

    Single value

    Right side multiplication parameter.

    Returns
    Type Description
    Vertex

    A new Vertex with the sum of a * b.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Subtraction(Vertex, Vertex)

    Subtraction is performed component-wise for every property.

    Declaration
    public static Vertex operator -(Vertex a, Vertex b)
    Parameters
    Type Name Description
    Vertex a

    Left side subtraction parameter.

    Vertex b

    Right side subtraction parameter.

    Returns
    Type Description
    Vertex

    A new Vertex with the sum of a - b.

    Remarks

    Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, make sure to normalize these properties.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023