Table of Contents

Class Polygon2D

Namespace
Godot
Assembly
GodotSharp.dll

A Polygon2D is defined by a set of points. Each point is connected to the next, with the final point being connected to the first, resulting in a closed polygon. Polygon2Ds can be filled with color (solid or gradient) or filled with a given texture.

public class Polygon2D : Node2D, IDisposable
Inheritance
Polygon2D
Implements
Inherited Members

Constructors

Polygon2D()

public Polygon2D()

Properties

Antialiased

If true, polygon edges will be anti-aliased.

public bool Antialiased { get; set; }

Property Value

bool

Bones

Internal list of Bone2D nodes used by the assigned Skeleton. Edited using the Polygon2D editor ("UV" button on the top toolbar).

public Array Bones { get; set; }

Property Value

Array

Color

The polygon's fill color. If Texture is set, it will be multiplied by this color. It will also be the default color for vertices not set in VertexColors.

public Color Color { get; set; }

Property Value

Color

InternalVertexCount

Number of internal vertices, used for UV mapping.

public int InternalVertexCount { get; set; }

Property Value

int

InvertBorder

Added padding applied to the bounding box when InvertEnabled is set to true. Setting this value too small may result in a "Bad Polygon" error.

public float InvertBorder { get; set; }

Property Value

float

InvertEnabled

If true, the polygon will be inverted, containing the area outside the defined points and extending to the InvertBorder.

public bool InvertEnabled { get; set; }

Property Value

bool

Offset

The offset applied to each vertex.

public Vector2 Offset { get; set; }

Property Value

Vector2

Polygon

The polygon's list of vertices. The final point will be connected to the first.

Note: This returns a copy of the Vector2[] rather than a reference.

public Vector2[] Polygon { get; set; }

Property Value

Vector2[]

Polygons

The list of polygons, in case more than one is being represented. Every individual polygon is stored as a int[] where each int is an index to a point in Polygon. If empty, this property will be ignored, and the resulting single polygon will be composed of all points in Polygon, using the order they are stored in.

public Array Polygons { get; set; }

Property Value

Array

Skeleton

Path to a Skeleton2D node used for skeleton-based deformations of this polygon. If empty or invalid, skeletal deformations will not be used.

public NodePath Skeleton { get; set; }

Property Value

NodePath

Texture

The polygon's fill texture. Use UV to set texture coordinates.

public Texture2D Texture { get; set; }

Property Value

Texture2D

TextureOffset

Amount to offset the polygon's Texture. If set to Vector2(0, 0), the texture's origin (its top-left corner) will be placed at the polygon's position.

public Vector2 TextureOffset { get; set; }

Property Value

Vector2

TextureRotation

The texture's rotation in radians.

public float TextureRotation { get; set; }

Property Value

float

TextureScale

Amount to multiply the UV coordinates when using Texture. Larger values make the texture smaller, and vice versa.

public Vector2 TextureScale { get; set; }

Property Value

Vector2

UV

Texture coordinates for each vertex of the polygon. There should be one UV value per polygon vertex. If there are fewer, undefined vertices will use Vector2(0, 0).

public Vector2[] UV { get; set; }

Property Value

Vector2[]

VertexColors

Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use Color.

public Color[] VertexColors { get; set; }

Property Value

Color[]

Methods

AddBone(NodePath, float[])

Adds a bone with the specified path and weights.

public void AddBone(NodePath path, float[] weights)

Parameters

path NodePath
weights float[]

ClearBones()

Removes all bones from this Polygon2D.

public void ClearBones()

EraseBone(int)

Removes the specified bone from this Polygon2D.

public void EraseBone(int index)

Parameters

index int

GetBoneCount()

Returns the number of bones in this Polygon2D.

public int GetBoneCount()

Returns

int

GetBonePath(int)

Returns the path to the node associated with the specified bone.

public NodePath GetBonePath(int index)

Parameters

index int

Returns

NodePath

GetBoneWeights(int)

Returns the weight values of the specified bone.

public float[] GetBoneWeights(int index)

Parameters

index int

Returns

float[]

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SetBonePath(int, NodePath)

Sets the path to the node associated with the specified bone.

public void SetBonePath(int index, NodePath path)

Parameters

index int
path NodePath

SetBoneWeights(int, float[])

Sets the weight values for the specified bone.

public void SetBoneWeights(int index, float[] weights)

Parameters

index int
weights float[]