Has something changed about @export variables

Godot Version

4.4.beta4

Question

Has something changed about @export variables and their timing in relation to @onready nodes, or am I just doing it wrong?

I used to be able to use something like:

@tool
extends PanelContainer

@export var item_name: String: set = _set_item_name
@onready var item_name_label: Label = %ItemNameLabel

func _set_item_name(_new_name: String) -> void:
     item_name = _new_name
     item_name_label.text = item_name

Where %ItemNameLabel is a child of the PanelContainer and that would let me set some names for things in-editor. But now, I’m just getting Node not found for anything where an @export variable is interacting with an @onready variable. Am I missing something?

I don’t think this every worked. The setter of the exported variable is called the first time when initializing at which point it was not yet added to the scene tree (i.e., _ready was not called yet).

You can check in _set_item_name if the node was already added to the tree (is_in_tree) or if the label is null.
You can check this proposal for onready setters where the problem is discussed. There are also some workaround in there: Implement `onready` setters · Issue #325 · godotengine/godot-proposals · GitHub

1 Like