Material Box

Material Box

WEB Design & Material Images

Godot - Getting the Number of Lines in a RichTextLabel

Godot

This code example shows how to get the number of lines in a RichTextLabel using GDScript.


You can use the `get_line_count()` function to get the number of lines in a RichTextLabel's text.
The number of lines returned by `get_line_count()` includes all lines, even those that are hidden due to the node's size or other factors.

var label = RichTextLabel.new()
add_child(label)
label.global_position = Vector2(0, 0)
label.size = Vector2(200,200)
label.text = "get
Line
count"

# Get the number of lines in RichTextLabel
var line_count = label.get_line_count()

print(line_count)
# 3

Godot

TitleGodot - Getting the Number of Lines in a RichTextLabel

CategoryGodot

Created

Update

AuthorYousuke.U