Godot 4.4
I’m having a strange behavior on one of my scripts, this is the script:
extends Control
@onready var icon : TextureRect = $ItemIcon
@onready var item_name : Label = $ItemName
@onready var time_to_craft : Label = $TimeToCraft
func _ready() -> void:
print("1: ",icon)
func init_node(_ico: CompressedTexture2D, it_name: String, tim_craft: float) -> void:
print(icon)
icon.texture = _ico
item_name.text = it_name
time_to_craft.text = str(tim_craft) + " Seconds"
Which gives me the error on runtime:
Invalid assignment of property or key ‘texture’ with value of type ‘CompressedTexture2D’ on a base object of type ‘Nil’.
So the error being, when I try to set the texture to the node, it complains about it being nil. To investigate this, I put the printing there, and as expected (As well as unexpected), the output was:
1: ItemIcon:<TextureRect#58518931328>
<null>
Is there a particular reason I’m missing this node suddenly becomes null? I tried setting manually a placeholder texture to it to make sure it has something to it’s texture parameter, but nothing happened.