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
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
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
InternalVertexCount
Number of internal vertices, used for UV mapping.
public int InternalVertexCount { get; set; }
Property Value
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
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
Offset
The offset applied to each vertex.
public Vector2 Offset { get; set; }
Property Value
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
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
Texture
The polygon's fill texture. Use UV to set texture coordinates.
public Texture2D Texture { get; set; }
Property Value
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
TextureRotation
The texture's rotation in radians.
public float TextureRotation { get; set; }
Property Value
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
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
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
GetBonePath(int)
Returns the path to the node associated with the specified bone.
public NodePath GetBonePath(int index)
Parameters
index
int
Returns
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
SetBonePath(int, NodePath)
Sets the path to the node associated with the specified bone.
public void SetBonePath(int index, NodePath path)
Parameters
SetBoneWeights(int, float[])
Sets the weight values for the specified bone.
public void SetBoneWeights(int index, float[] weights)