Godot Version
v4.3.stable.mono.official [77dcf97d8]
Question
Hi everybody,
In my program, I have a 2D coordinates system that user can enter at different places in the UI. To achieve that, I created a scene that contains 2 spinboxes :
In the “_Ready” method of this scene’s script, I added the following lines to trace something strange that happens :
GD.Print("SpinX : " + FindChild("Xspin"));
SpinBox x = (SpinBox)FindChild("Xspin");
if (x == null) {
GD.Print("SpinBox X is null");
} else {
GD.Print("SpinBox X : " + x);
}
When I run my project using this scene as default scene, Everything is OK as shown by the logs :
SpinX : <SpinBox#24914167056>
SpinBox X : <SpinBox#24914167056>
My problem is that, when I try to add this scene as a control in another scene using script, by creating an instance of the control and adding it to a container, scene’s inner nodes are not found :
SpinX :
SpinBox X is null
Am I missing something ?
EDIT :
I tried to had another log trace :
GD.Print("in PositionControl._Ready : Control has " + GetChildCount() + " child(ren)");
and the behavior is the same :
- When control is directly put in another scene by scene designer, it Ok (log says it has 4 children).
- When control is created and added by script, log says it has 0 child
I’m wondering if it’s not an “event” problem : may be “_ready” is not the right place to check scene children when added by script…