2024-05-27 18:22:20 +03:00
|
|
|
@tool
|
|
|
|
extends Node3D
|
|
|
|
|
2024-05-27 19:16:45 +03:00
|
|
|
const LabelFont = preload ("res://assets/fonts/Raleway-Medium.ttf")
|
2024-05-27 18:22:20 +03:00
|
|
|
|
|
|
|
@onready var label = $Body/Label3D
|
|
|
|
@onready var collision = $Body/CollisionShape3D
|
|
|
|
@onready var area_collision = $Area3D/CollisionShape3D
|
|
|
|
|
|
|
|
var text = "test"
|
|
|
|
var value = ""
|
|
|
|
var disabled = false:
|
|
|
|
set(value):
|
|
|
|
disabled = value
|
|
|
|
|
|
|
|
if is_node_ready() == false: return
|
|
|
|
|
|
|
|
collision.disabled = value
|
|
|
|
area_collision.disabled = value
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
label.text = text
|
|
|
|
|
|
|
|
_update()
|
|
|
|
|
|
|
|
func get_size() -> Vector2:
|
2024-05-27 19:16:45 +03:00
|
|
|
return LabelFont.get_string_size(text, HORIZONTAL_ALIGNMENT_LEFT, 10000, 18) * 0.001
|
2024-05-27 18:22:20 +03:00
|
|
|
|
|
|
|
func _update():
|
|
|
|
var size = get_size()
|
|
|
|
collision.shape.size = Vector3(size.x, size.y, 0.004)
|
|
|
|
area_collision.shape.size = Vector3(size.x, size.y, 0.01)
|
|
|
|
collision.position = Vector3(size.x / 2, -size.y / 2, 0.002)
|
2024-05-27 19:16:45 +03:00
|
|
|
area_collision.position = Vector3(size.x / 2, -size.y / 2, 0.005)
|