I created a component, that I want to reuse and it has it’s own children. When adding them with the GUI + Add child node, it’s children are not created. When I drag and drop it from the file system, it is created as packed scene and thus the children are created. Shouldn’t this be the behavior when adding as child as well?
I have this component that is wrapping 3 Timers, and automates some logic and provides a custom signal. It has a class_name so it appears in the children menu. Is there a mark or something that lets me tell godot - hey always add this as a packed scene?
It took me some time to understand what is happening, but it doesn’t feel like this should be the intended functionality. Is there a reason for it to behave as such?
A scene (PackedScene) is different from a Script (code + class name etc.)
When you make a script that extends some kind of Node, that can be added as a Node (to the tree) but for it to supply children etc. it would have to run code to add them. You could have that script preload the scene file and then add that as a child, for example. Look into preload, add_child etc.
Thanks for the answer.
Yes, it just took me by surprise, when nothing was loading.
Is there a way to tell a script or godot use this only as a packed scene. Like in the script at the top having @packed(“./path/to/scene”) - so that when it is added with the + add child it is automatically added as a packed scene? Or some other way to achieve that, so that adding it trough the GUI works? Adding it with preload and add_child will result in not being able to use gui to set things like @export variables and linking signals easily. I understand they still can be changed with code just not as easily.
I am struggling to grasp what you are experiencing. If you make a small demo project that can show me the situation, I’ll have a better chance of trying to help.