platformerNavigation/Inspector/InspectorDisplay.gd

32 lines
601 B
GDScript3
Raw Permalink Normal View History

2024-03-11 12:41:54 +00:00
extends HBoxContainer
@export var target: Node2D
@export var property: String
@export var label = ""
@onready var labelNode = $Label
@onready var valueNode = $Value
func _ready():
labelNode.text = label
update()
func update():
valueNode.text = formatValue(target.get(property))
func formatValue(value):
match typeof(value):
TYPE_BOOL:
return "%s" % value
TYPE_INT:
return "%d" % value
TYPE_FLOAT:
return "%.02f" % value
TYPE_STRING:
return value
TYPE_VECTOR2:
return "%.02f %.02f" % [value.x, value.y]
func _process(delta):
update()