docs.unity3d.com
    Show / Hide Table of Contents

    Struct Edge

    Represents an edge connecting two vertices.

    This might point to an index in the GetVertices(IList<Int32>) (local) or the sharedVertices (common) array. The ProBuilder terminology "local" and "common" refers to whether this is an index from the list of all vertices in the ProBuilderMesh or an index from the list of only shared vertices.

    Inherited Members
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: UnityEngine.ProBuilder
    Syntax
    [Serializable]
    public struct Edge : IEquatable<Edge>

    Constructors

    Edge(Int32, Int32)

    Creates a new edge from two vertex indexes.

    Declaration
    public Edge(int a, int b)
    Parameters
    Type Name Description
    Int32 a

    An index corresponding to a mesh vertex array.

    Int32 b

    An index corresponding to a mesh vertex array.

    Fields

    a

    Stores an index that corresponds to a mesh vertex array.

    Declaration
    public int a
    Field Value
    Type Description
    Int32

    b

    Stores an index that corresponds to a mesh vertex array.

    Declaration
    public int b
    Field Value
    Type Description
    Int32

    Empty

    Creates an empty edge defined as (-1, -1).

    Declaration
    public static readonly Edge Empty
    Field Value
    Type Description
    Edge

    Methods

    Add(Edge, Edge)

    Adds two edges index values.

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

    Left edge parameter.

    Edge b

    Right edge parameter.

    Returns
    Type Description
    Edge

    The sum of a + b.

    Examples

    {0, 1} + {4, 5} = {5, 6}

    Contains(Int32)

    Tests whether this edge contains an index.

    Declaration
    public bool Contains(int index)
    Parameters
    Type Name Description
    Int32 index

    The index to compare against x and y.

    Returns
    Type Description
    Boolean

    True if x or y is equal to a. False if not.

    Contains(Edge)

    Tests whether this edge has any matching index to the other edge b.

    Declaration
    public bool Contains(Edge other)
    Parameters
    Type Name Description
    Edge other

    The edge to compare against.

    Returns
    Type Description
    Boolean

    True if x or y matches either b.x or b.y.

    Equals(Object)

    Tests whether this object is equal to another object.

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

    The object to compare against.

    Returns
    Type Description
    Boolean

    True if the edges are equal, false if not.

    Overrides
    ValueType.Equals(Object)

    Equals(Edge)

    Tests whether this Edge is equal to another Edge object.

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

    The Edge to compare against.

    Returns
    Type Description
    Boolean

    True if the edges are equal, false if not.

    Implements
    IEquatable<T>.Equals(T)

    Equals(Edge, Dictionary<Int32, Int32>)

    Compares edges and takes shared triangles into account.

    Declaration
    public bool Equals(Edge other, Dictionary<int, int> lookup)
    Parameters
    Type Name Description
    Edge other

    The edge to compare against.

    Dictionary<Int32, Int32> lookup

    A common vertex indexes lookup dictionary. See pb_IntArray for more information.

    Returns
    Type Description
    Boolean

    True if edges are perceptually equal (that is, they point to the same common indexes).

    Remarks

    Generally you just pass ProBuilderMesh.sharedIndexes.ToDictionary() to lookup, but it's more efficient to do it once and reuse that dictionary if possible.

    GetHashCode()

    Returns the hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    An integer that is the hash code for this instance.

    Overrides
    ValueType.GetHashCode()

    IsValid()

    Tests whether this edge points to valid vertex indexes.

    Declaration
    public bool IsValid()
    Returns
    Type Description
    Boolean

    True if x and y are both greater than -1.

    Subtract(Edge, Edge)

    Subtracts edge b from a.

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

    The edge to subtract from.

    Edge b

    The value to subtract.

    Returns
    Type Description
    Edge

    The difference of a - b.

    Examples

    Subtract( {7, 10}, {4, 5} ) = {3, 5}

    ToString()

    Returns a string representation of the edge.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    String formatted as [a, b].

    Overrides
    ValueType.ToString()

    Operators

    Addition(Edge, Int32)

    Creates a new Edge by adding an integer to both indices on an Edge object.

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

    The Edge to add to.

    Int32 b

    The value to add.

    Returns
    Type Description
    Edge

    A new edge where {x, y} = {(a.a + b), (a.b + b)}.

    Addition(Edge, Edge)

    Creates a new Edge by adding the two left indices together and the two right indices together from both Edge objects.

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

    Left edge.

    Edge b

    Right edge.

    Returns
    Type Description
    Edge

    A new edge where {x, y} = {(a.a + b.a), (a.b + b.b)}.

    Equality(Edge, Edge)

    Compares two objects for equality.

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

    The first Edge instance.

    Edge b

    The second Edge instance.

    Returns
    Type Description
    Boolean

    True if the objects are equal; false if not.

    Inequality(Edge, Edge)

    Returns true if the two objects are not equal.

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

    The first Edge instance.

    Edge b

    The second Edge instance.

    Returns
    Type Description
    Boolean

    True if the objects are not equal; false if they are equal.

    Subtraction(Edge, Int32)

    Creates a new Edge by subtracting an integer from both indices on an Edge object.

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

    The Edge to subtract from.

    Int32 b

    The value to subtract.

    Returns
    Type Description
    Edge

    A new edge where {x, y} = {(a.a - b), (a.b - b)}.

    Subtraction(Edge, Edge)

    Creates a new Edge by subtracting the two left indices together and the two right indices together from both Edge objects.

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

    Left edge.

    Edge b

    Right edge.

    Returns
    Type Description
    Edge

    A new edge where {x, y} = {(a.a - b.a), (a.b - b.b)}.

    See Also

    sharedVertices
    EdgeLookup
    Back to top
    Terms of use
    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