Class Label
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A control for displaying plain text. It gives you control over the horizontal and vertical alignment and can wrap the text inside the node's bounding rectangle. It doesn't support bold, italics, or other rich text formatting. For that, use RichTextLabel instead.
public class Label : Control, IDisposable
- Inheritance
-
Label
- Implements
- Inherited Members
Constructors
Label()
public Label()
Properties
AutowrapMode
If set to something other than Off, the text gets wrapped inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text. To see how each mode behaves, see TextServer.AutowrapMode.
public TextServer.AutowrapMode AutowrapMode { get; set; }
Property Value
ClipText
If true
, the Label only shows the text that fits inside its bounding rectangle and will clip text horizontally.
public bool ClipText { get; set; }
Property Value
HorizontalAlignment
Controls the text's horizontal alignment. Supports left, center, right, and fill, or justify. Set it to one of the HorizontalAlignment constants.
public HorizontalAlignment HorizontalAlignment { get; set; }
Property Value
JustificationFlags
Line fill alignment rules. For more info see TextServer.JustificationFlag.
public TextServer.JustificationFlag JustificationFlags { get; set; }
Property Value
LabelSettings
A LabelSettings resource that can be shared between multiple Label nodes. Takes priority over theme properties.
public LabelSettings LabelSettings { get; set; }
Property Value
Language
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
public string Language { get; set; }
Property Value
LinesSkipped
The number of the lines ignored and not displayed from the start of the Text value.
public int LinesSkipped { get; set; }
Property Value
MaxLinesVisible
Limits the lines of text the node shows on screen.
public int MaxLinesVisible { get; set; }
Property Value
StructuredTextBidiOverride
Set BiDi algorithm override for the structured text.
public TextServer.StructuredTextParser StructuredTextBidiOverride { get; set; }
Property Value
StructuredTextBidiOverrideOptions
Set additional options for BiDi override.
public Array StructuredTextBidiOverrideOptions { get; set; }
Property Value
TabStops
Aligns text to the given tab-stops.
public float[] TabStops { get; set; }
Property Value
- float[]
Text
The text to display on screen.
public string Text { get; set; }
Property Value
TextDirection
Base text writing direction.
public Control.TextDirection TextDirection { get; set; }
Property Value
TextOverrunBehavior
Sets the clipping behavior when the text exceeds the node's bounding rectangle. See TextServer.OverrunBehavior for a description of all modes.
public TextServer.OverrunBehavior TextOverrunBehavior { get; set; }
Property Value
Uppercase
If true
, all the text displays as UPPERCASE.
public bool Uppercase { get; set; }
Property Value
VerticalAlignment
Controls the text's vertical alignment. Supports top, center, bottom, and fill. Set it to one of the VerticalAlignment constants.
public VerticalAlignment VerticalAlignment { get; set; }
Property Value
VisibleCharacters
The number of characters to display. If set to -1
, all characters are displayed. This can be useful when animating the text appearing in a dialog box.
Note: Setting this property updates VisibleRatio accordingly.
public int VisibleCharacters { get; set; }
Property Value
VisibleCharactersBehavior
Sets the clipping behavior when VisibleCharacters or VisibleRatio is set. See TextServer.VisibleCharactersBehavior for more info.
public TextServer.VisibleCharactersBehavior VisibleCharactersBehavior { get; set; }
Property Value
VisibleRatio
The fraction of characters to display, relative to the total number of characters (see GetTotalCharacterCount()). If set to 1.0
, all characters are displayed. If set to 0.5
, only half of the characters will be displayed. This can be useful when animating the text appearing in a dialog box.
Note: Setting this property updates VisibleCharacters accordingly.
public float VisibleRatio { get; set; }
Property Value
Methods
GetLineCount()
Returns the number of lines of text the Label has.
public int GetLineCount()
Returns
GetLineHeight(int)
Returns the height of the line line
.
If line
is set to -1
, returns the biggest line height.
If there are no lines, returns font size in pixels.
public int GetLineHeight(int line = -1)
Parameters
line
int
Returns
GetTotalCharacterCount()
Returns the total number of printable characters in the text (excluding spaces and newlines).
public int GetTotalCharacterCount()
Returns
GetVisibleLineCount()
Returns the number of lines shown. Useful if the Label's height cannot currently display all lines.
public int GetVisibleLineCount()
Returns
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.