Godot Version
Godot 4.3
Question
I have a project where I have a class “Child” , a Node2D with a Sprite2D and Texture as exported properties. Here’s the code:
extends Node2D
class_name Child
@export var sprite_2d: Sprite2D
@export var default_texture: Texture
func _ready() -> void:
sprite_2d.texture = default_texture
When I attempt to run this scene by itself everything is fine, however when I create an instance of Child and attempt to call “add_child”, the debugger says that the exported properties for Child have not been set. Here’s the code for that:
extends ColorRect
class_name Parent
@export var child: Child
func _ready() -> void:
child = Child.new()
add_child(child)
(Note that Parent also has exported property storing a reference to Child)
Also here’s a screenshot of the error I’m getting:
Can anyone help me figure out why this is happening?