• Godot HelpProgramming
  • _enter_tree() for an "instance child scene" added node to another scene is not called

When the containing node is run as a program the instanced scene's calls are made. When the containing node is used as a main screen the instanced scene's call is not.

Is this correct ? Or have I missed something?

The containing scene's _enter_tree() -is- called.

Whenever a node is added to the scene, enter_tree is called without condition.

Not entirely true, scripts for scene trees added as https://docs.godotengine.org/en/stable/tutorials/plugins/editor/making_main_screen_plugins.html

must be flagged with the tool keyword, or the script extensions are -not- available from the editor. Every script attached to my implementation attached to a main_screen scene tree must also have this keyword.

But this means that instanced scenes added to the editor-main-screen-scene also need to flagged this way, but if I write a generic scene that might want to run only in game in other circumstances, then the keyword is conflicting to purpose; every script in that scene must also be labeled with the tool keyword.

Yes I understand that, but my oversight was not remembering that all scripts must have the keyword flagged. The bummer in this single mechanism is that I developed a general "widget" packed in its own scene. Without the tool keyword, the scripts were inert, but it can't be pure; you need to hack it to work purely in the editor, in game or a mix.

I want instances of it to run purely 'in game' in other circumstances, I will have to copy and remove the keyword because a generic widget cannot make decisions about the correct context to run in. In short, editor_hint is not helpful.

It would be 'nice' to have some way of saying a scene-tree is "editor" in such a way that other scenes inserted in it can also be treated as 'tool', either that or have a 'load as if identified as tool'.

So create a instancer node that instances a specific "race" depending on the state of the editor hint.

I had considered that, but the virtue of being able to include the widget scene through the editor is high. The widget can be configured through the inspector, themed. Instancing two distinct scenes creates a project where the relative paths of the races must be declared and maintained in code.

3 years later