Class Vertex
Holds information about a single vertex, and provides methods for averaging between multiple Vertex objects.
Inherited Members
Namespace: UnityEngine.ProBuilder
Syntax
[Serializable]
public sealed class Vertex : IEquatable<Vertex>
Remarks
All values are optional; however, ProBuilder can use default values if necessary.
Constructors
Vertex()
Initializes a Vertex with no values.
Declaration
public Vertex()
Vertex(Vertex)
Creates a new Vertex object as a copy of another Vertex object.
Declaration
public Vertex(Vertex vertex)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | vertex | The Vertex to copy field data from. |
Properties
color
Gets or sets the vertex color.
Declaration
public Color color { get; set; }
Property Value
| Type | Description |
|---|---|
| Color | The color applied to this vertex. |
See Also
normal
Gets or sets the unit vector normal.
Declaration
public Vector3 normal { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 | The unit vector normal. |
See Also
position
Gets or sets the position in local space.
Declaration
public Vector3 position { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 | The position in local space. |
See Also
tangent
Gets or sets the vertex tangent (sometimes called binormal).
Declaration
public Vector4 tangent { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector4 | The vertex tangent. |
See Also
uv0
Gets or sets the UV0 channel. Also called texture UVs.
Declaration
public Vector2 uv0 { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 | The UV0 channel. |
See Also
uv2
Gets or sets the UV2 channel.
Declaration
public Vector2 uv2 { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 | The UV2 channel. |
See Also
uv3
Gets or sets the UV3 channel.
Declaration
public Vector4 uv3 { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector4 | The UV3 channel. |
See Also
uv4
Gets or sets the UV4 channel.
Declaration
public Vector4 uv4 { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector4 | The UV4 channel. |
See Also
Methods
Add(Vertex)
Adds another Vertex object to this one using component-wise addition on each attribute.
Declaration
public void Add(Vertex b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | b | The Vertex object to add. |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Add(Vertex, Vertex)
Adds two Vertex objects together and returns the result in a new Vertex object. Addition is performed component-wise for every attribute on the Vertex.
Declaration
public static Vertex Add(Vertex a, Vertex b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | First Vertex object. |
| Vertex | b | Second Vertex object. |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex with the sum of |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Average(IList<Vertex>, IList<Int32>)
Averages all vertices to a single vertex and returns the result as a new Vertex object.
Declaration
public static Vertex Average(IList<Vertex> vertices, IList<int> indexes = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Vertex> | vertices | The list of vertices to average. |
| IList<Int32> | indexes | Specify a list of vertex points to calculate the average from. If not specified, it averages the entire set of vertices instead. |
Returns
| Type | Description |
|---|---|
| Vertex | An averaged vertex value. |
Divide(Single)
Divides this Vertex object by the specified value using component-wise division on each attribute.
Declaration
public void Divide(float value)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | value | Divisor. |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Divide(Vertex, Single)
Divides a Vertex object by the specified value and returns the result in a new Vertex object.
Division is performed component-wise for every attribute.
Declaration
public static Vertex Divide(Vertex a, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | Vertex object to divide (dividend). |
| Single | value | Divisor. |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex with the quotient of |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Equals(Object)
Determines whether the specified generic object is equal to this Vertex.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj | The object to compare this Vertex object to. |
Returns
| Type | Description |
|---|---|
| Boolean | True if the other object is a Vertex and is equal to this. |
Overrides
Equals(Vertex)
Determines whether the specified Vertex object is equal to this Vertex by checking whether all components are within a certain distance of the other.
Declaration
public bool Equals(Vertex other)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | other | The other Vertex to compare to. |
Returns
| Type | Description |
|---|---|
| Boolean | True if all values are the same (within float.Epsilon). |
Implements
Equals(Vertex, MeshArrays)
Determines whether the specified Vertex object is equal to this Vertex by checking whether each
component for a specific set of attributes is within a certain distance of the other. The MeshArrays
mask determines which set of attributes to compare.
Declaration
public bool Equals(Vertex other, MeshArrays mask)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | other | The other Vertex to compare to. |
| MeshArrays | mask | A bitmask that defines which attributes to compare. |
Returns
| Type | Description |
|---|---|
| Boolean | True if all values are the same (within float.Epsilon). |
GetArrays(IList<Vertex>, out Vector3[], out Color[], out Vector2[], out Vector3[], out Vector4[], out Vector2[], out List<Vector4>, out List<Vector4>)
Allocates and fills all attribute arrays. This method fills all arrays, regardless of whether or not
real data populates the values. You can check which 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(Mesh, IList<Vertex>) instead. SetMesh handles setting null arrays where appropriate.
GetArrays(IList<Vertex>, out Vector3[], out Color[], out Vector2[], out Vector3[], out Vector4[], out Vector2[], out List<Vector4>, out List<Vector4>, MeshArrays)
Allocates and fills the specified 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 bitmask of the set of MeshAttributes you want. |
Remarks
If you are using this function to rebuild a mesh, use SetMesh(Mesh, IList<Vertex>) instead. SetMesh handles setting null arrays where appropriate.
See Also
GetHashCode()
Creates a new hashcode from this Vertex's position, UV0, and normal.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| Int32 | A hashcode for this object. |
Overrides
HasArrays(MeshArrays)
Tests whether the specified vertex attribute has been set.
Declaration
public bool HasArrays(MeshArrays attribute)
Parameters
| Type | Name | Description |
|---|---|---|
| MeshArrays | attribute | An array containing one or more attribute(s) to find. |
Returns
| Type | Description |
|---|---|
| Boolean | True if this vertex has the specified attributes set; false if they are default values. |
Mix(Vertex, Vertex, Single)
Linearly interpolates between two vertices using the specified weight.
Declaration
public static Vertex Mix(Vertex x, Vertex y, float weight)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | x | The first Vertex object. |
| Vertex | y | The second Vertex object. |
| Single | weight | The weight of the interpolation, where |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex object interpolated between the two objects according to the specified |
Multiply(Single)
Multiples this Vertex object by the specified value using component-wise multiplication on each attribute.
Declaration
public void Multiply(float value)
Parameters
| Type | Name | Description |
|---|---|---|
| Single | value | Multiplication factor. |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Multiply(Vertex, Single)
Multiples a Vertex object by the specified value and returns the result in a new Vertex object.
Multiplication is performed component-wise for every attribute on the Vertex.
Declaration
public static Vertex Multiply(Vertex a, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | Vertex object to multiply |
| Single | value | Multiplication factor. |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex with the product of |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Normalize()
Normalizes all vector values in place.
Declaration
public void Normalize()
SetMesh(Mesh, IList<Vertex>)
Replaces mesh values with the specified vertex array. The mesh is cleared during this function, so you need to set the triangles after calling this method.
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)
Subtracts another Vertex object from this one using component-wise subtraction on each attribute.
Declaration
public void Subtract(Vertex b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | b | The Vertex object to subtract. |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Subtract(Vertex, Vertex)
Subtracts two Vertex objects and returns the result in a new Vertex object. Subtraction is performed component-wise for every attribute on the Vertex.
Declaration
public static Vertex Subtract(Vertex a, Vertex b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | First Vertex object. |
| Vertex | b | Second Vertex object. |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex with the difference of |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
ToString(String)
Returns a multi-line string listing every populated attribute.
Declaration
public string ToString(string args = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | args | An optional string argument to pass to the component ToString calls. |
Returns
| Type | Description |
|---|---|
| String | A string with the values of all populated attributes. |
Operators
Addition(Vertex, Vertex)
Adds two Vertex objects together and returns the result in a new Vertex object. Addition is performed component-wise for every attribute on the Vertex.
Declaration
public static Vertex operator +(Vertex a, Vertex b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | Left operand. |
| Vertex | b | Right operand. |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex with the sum of |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Division(Vertex, Single)
Divides a Vertex object by the specified value and returns the result in a new Vertex object.
Division is performed component-wise for every attribute.
Declaration
public static Vertex operator /(Vertex a, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | Vertex object to divide (dividend). |
| Single | value | Divisor. |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex with the quotient of |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Equality(Vertex, Vertex)
Determines whether the specified Vertex is equal to this one.
Declaration
public static bool operator ==(Vertex a, Vertex b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | Left operand. |
| Vertex | b | Right operand. |
Returns
| Type | Description |
|---|---|
| Boolean | True if |
Inequality(Vertex, Vertex)
Determines whether the specified Vertex is not equal to this one.
Declaration
public static bool operator !=(Vertex a, Vertex b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | Left operand. |
| Vertex | b | Right operand. |
Returns
| Type | Description |
|---|---|
| Boolean | True if |
Multiply(Vertex, Single)
Multiples a Vertex object by the specified value and returns the result in a new Vertex object.
Multiplication is performed component-wise for every attribute.
Declaration
public static Vertex operator *(Vertex a, float value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | Vertex object to multiply |
| Single | value | Multiplication factor. |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex with the product of |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.
Subtraction(Vertex, Vertex)
Subtracts two Vertex objects and returns the result in a new Vertex object. Subtraction is performed component-wise for every attribute.
Declaration
public static Vertex operator -(Vertex a, Vertex b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vertex | a | Left operand. |
| Vertex | b | Right operand. |
Returns
| Type | Description |
|---|---|
| Vertex | A new Vertex with the difference of |
Remarks
Color, normal, and tangent values are not normalized within this function. If you are expecting unit vectors, you need to normalize these attributes.