Struct Edge | ProBuilder | 4.3.1
docs.unity3d.com
    Show / Hide Table of Contents

    Struct Edge

    An edge connecting two vertices. May point to an index in the vertices or the sharedIndexes array (local / common in ProBuilder terminology).

    Namespace: UnityEngine.ProBuilder
    Syntax
    [Serializable]
    public struct Edge : IEquatable<Edge>

    Constructors

    Edge(Int32, Int32)

    Create 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

    Declaration
    public int a
    Field Value
    Type Description
    Int32

    An index corresponding to a mesh vertex array.

    b

    Declaration
    public int b
    Field Value
    Type Description
    Int32

    An index corresponding to a mesh vertex array.

    Empty

    Declaration
    public static readonly Edge Empty
    Field Value
    Type Description
    Edge

    An empty edge is defined as -1, -1.

    Methods

    Add(Edge, Edge)

    Add 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)

    Does this edge contain 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)

    Does this edge have any matching index to 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)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    ValueType.Equals(Object)

    Equals(Edge)

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

    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()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    ValueType.GetHashCode()

    IsValid()

    Test if 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)

    Subtract 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 sum of a - b.

    Examples

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

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    ValueType.ToString()

    Operators

    Addition(Edge, Int32)

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

    Addition(Edge, Edge)

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

    Equality(Edge, Edge)

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

    Inequality(Edge, Edge)

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

    Subtraction(Edge, Int32)

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

    Subtraction(Edge, Edge)

    Declaration
    public static Edge operator -(Edge a, Edge b)
    Parameters
    Type Name Description
    Edge a
    Edge b
    Returns
    Type Description
    Edge
    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