Class Polygon | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class Polygon

    A polygon represented as a planar straight line graph.

    Inheritance
    System.Object
    Polygon
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: UnityEngine.Experimental.U2D.TriangleNet.Geometry
    Syntax
    public class Polygon : IPolygon

    Constructors

    Polygon()

    Initializes a new instance of the Polygon class.

    Declaration
    public Polygon()

    Polygon(Int32)

    Initializes a new instance of the Polygon class.

    Declaration
    public Polygon(int capacity)
    Parameters
    Type Name Description
    System.Int32 capacity

    The default capacity for the points list.

    Polygon(Int32, Boolean)

    Initializes a new instance of the Polygon class.

    Declaration
    public Polygon(int capacity, bool markers)
    Parameters
    Type Name Description
    System.Int32 capacity

    The default capacity for the points list.

    System.Boolean markers

    Use point and segment markers.

    Properties

    Count

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    HasPointMarkers

    Gets or sets a value indicating whether the vertices have marks or not.

    Declaration
    public bool HasPointMarkers { get; set; }
    Property Value
    Type Description
    System.Boolean
    Implements
    IPolygon.HasPointMarkers

    HasSegmentMarkers

    Gets or sets a value indicating whether the segments have marks or not.

    Declaration
    public bool HasSegmentMarkers { get; set; }
    Property Value
    Type Description
    System.Boolean
    Implements
    IPolygon.HasSegmentMarkers

    Holes

    Gets a list of points defining the holes of the polygon.

    Declaration
    public List<Point> Holes { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<Point>
    Implements
    IPolygon.Holes

    Points

    Gets the vertices of the polygon.

    Declaration
    public List<Vertex> Points { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<Vertex>
    Implements
    IPolygon.Points

    Regions

    Gets a list of pointers defining the regions of the polygon.

    Declaration
    public List<RegionPointer> Regions { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<RegionPointer>
    Implements
    IPolygon.Regions

    Segments

    Gets the segments of the polygon.

    Declaration
    public List<ISegment> Segments { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<ISegment>
    Implements
    IPolygon.Segments

    Methods

    Add(Contour, Boolean)

    Add a contour to the polygon.

    Declaration
    public void Add(Contour contour, bool hole = false)
    Parameters
    Type Name Description
    Contour contour

    The contour to insert.

    System.Boolean hole

    Treat contour as a hole.

    Implements
    IPolygon.Add(Contour, Boolean)

    Add(Contour, Point)

    Add a contour to the polygon.

    Declaration
    public void Add(Contour contour, Point hole)
    Parameters
    Type Name Description
    Contour contour

    The contour to insert.

    Point hole

    Point inside the contour, making it a hole.

    Implements
    IPolygon.Add(Contour, Point)

    Add(ISegment, Boolean)

    Add a segment to the polygon.

    Declaration
    public void Add(ISegment segment, bool insert = false)
    Parameters
    Type Name Description
    ISegment segment

    The segment to insert.

    System.Boolean insert

    If true, both endpoints will be added to the points list.

    Implements
    IPolygon.Add(ISegment, Boolean)

    Add(ISegment, Int32)

    Add a segment to the polygon.

    Declaration
    public void Add(ISegment segment, int index)
    Parameters
    Type Name Description
    ISegment segment

    The segment to insert.

    System.Int32 index

    The index of the segment endpoint to add to the points list (must be 0 or 1).

    Implements
    IPolygon.Add(ISegment, Int32)

    Add(Vertex)

    Add a vertex to the polygon.

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

    The vertex to insert.

    Implements
    IPolygon.Add(Vertex)

    AddContour(IEnumerable<Vertex>, Int32, Boolean, Boolean)

    Declaration
    [Obsolete("Use polygon.Add(contour) method instead.")]
    public void AddContour(IEnumerable<Vertex> points, int marker = 0, bool hole = false, bool convex = false)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<Vertex> points
    System.Int32 marker
    System.Boolean hole
    System.Boolean convex
    Implements
    IPolygon.AddContour(IEnumerable<Vertex>, Int32, Boolean, Boolean)

    AddContour(IEnumerable<Vertex>, Int32, Point)

    Declaration
    [Obsolete("Use polygon.Add(contour) method instead.")]
    public void AddContour(IEnumerable<Vertex> points, int marker, Point hole)
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<Vertex> points
    System.Int32 marker
    Point hole
    Implements
    IPolygon.AddContour(IEnumerable<Vertex>, Int32, Point)

    Bounds()

    Compute the bounds of the polygon.

    Declaration
    public Rectangle Bounds()
    Returns
    Type Description
    Rectangle

    Rectangle defining an axis-aligned bounding box.

    Implements
    IPolygon.Bounds()
    In This Article
    • Constructors
      • Polygon()
      • Polygon(Int32)
      • Polygon(Int32, Boolean)
    • Properties
      • Count
      • HasPointMarkers
      • HasSegmentMarkers
      • Holes
      • Points
      • Regions
      • Segments
    • Methods
      • Add(Contour, Boolean)
      • Add(Contour, Point)
      • Add(ISegment, Boolean)
      • Add(ISegment, Int32)
      • Add(Vertex)
      • AddContour(IEnumerable<Vertex>, Int32, Boolean, Boolean)
      • AddContour(IEnumerable<Vertex>, Int32, Point)
      • Bounds()
    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