immersive-home/app/content/ui/components/label_container/label_container.gd

34 lines
668 B
GDScript3
Raw Normal View History

2024-04-24 15:00:08 +03:00
@tool
extends Container3D
class_name LabelContainer3D
const FontTools = preload ("res://lib/utils/font_tools.gd")
@onready var label: Label3D = $Label3D
@export var text: String = "Example":
set(value):
text = value
if !is_inside_tree(): return
_update_text()
2024-04-25 14:19:12 +03:00
@export var font_size: int = 18:
set(value):
font_size = value
if !is_inside_tree(): return
_update_text()
2024-04-24 15:00:08 +03:00
func _ready():
print("label %s enter tree" % text)
_update_text()
func _update_text():
2024-04-25 14:19:12 +03:00
label.font_size = font_size
2024-04-24 15:00:08 +03:00
label.text = text
var text_size = FontTools.get_font_size(label)
size = Vector3(text_size.x, text_size.y, 0.1)
print("label %s size %s" % [text, size])