trijam-355-inconvenient-sup.../scripts/debug_label.gd

36 lines
970 B
GDScript

@tool
#@icon
class_name DebugLabel
extends HBoxContainer
## Easy-to-use(?) container for visualizing variables
## Signals
## Enums
## Constants
## @export variables
@export var target: Node ## The Node this label applies to (usually its parent)
@export var variable_name: String ## The variable this label displays; check spelling and casing
## Regular variables
## @onready variables
@onready var title_label: Label = $TitleLabel
@onready var value_label: Label = $ValueLabel
## Overridden built-in virtual methods
#func _init() -> void:
#func _enter_tree() -> void:
func _ready() -> void:
title_label.text = variable_name.capitalize() + ": "
func _process(_delta: float) -> void:
if not Engine.is_editor_hint():
if target:
if variable_name:
var value = target.get(variable_name)
value_label.text = str(value)
#func _physics_process(delta: float) -> void:
## Remaining virtual methods
## Overridden custom methods
## Remaining methods
## Subclasses