Class Vertex
Holds information about a single vertex, and provides methods for averaging between many.
Inheritance
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
normal
Declaration
public Vector3 normal { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 | Unit vector normal. |
See Also
position
Declaration
public Vector3 position { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector3 | The position in model space. |
See Also
tangent
Declaration
public Vector4 tangent { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector4 | Vertex tangent (sometimes called binormal). |
See Also
uv0
Declaration
public Vector2 uv0 { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 | UV 0 channel. Also called textures. |
See Also
uv2
Declaration
public Vector2 uv2 { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 | UV 2 channel. |
See Also
uv3
Declaration
public Vector4 uv3 { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector4 | UV 3 channel. |
See Also
uv4
Declaration
public Vector4 uv4 { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector4 | UV 4 channel. |
See Also
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 |
|---|---|---|
| System.Collections.Generic.IList<Vertex> | vertices | A list of vertices. |
| System.Collections.Generic.IList<System.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 |
|---|---|---|
| System.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. |
| System.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 |
|---|---|---|
| System.Object | obj | The object to compare this vertex to. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if obj is a Vertex, and equal to this. |
Overrides
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 |
|---|---|
| System.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 |
|---|---|
| System.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 |
|---|---|---|
| System.Collections.Generic.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. |
| System.Collections.Generic.List<Vector4> | uv3 | A new array of the vertex uv3 values. |
| System.Collections.Generic.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
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 |
|---|---|---|
| System.Collections.Generic.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. |
| System.Collections.Generic.List<Vector4> | uv3 | A new array of the vertex uv3 values if requested by the attributes parameter, or null. |
| System.Collections.Generic.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
GetHashCode()
Creates a new hashcode from position, uv0, and normal.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | A hashcode for this object. |
Overrides
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 |
|---|---|
| System.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. |
| System.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 |
|---|---|---|
| System.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. |
| System.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. |
| System.Collections.Generic.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 |
|---|---|---|
| System.String | args | An optional string argument that is provided to the component ToString calls. |
Returns
| Type | Description |
|---|---|
| System.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. |
| System.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 |
|---|---|
| System.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 |
|---|---|
| System.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. |
| System.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.