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():
|
|
|
|
_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)
|
2024-04-25 17:05:52 +03:00
|
|
|
size = Vector3(text_size.x, text_size.y, 0.1)
|