Godot: Tool script created child doesn't shows in scene tree

Created on 8 Sep 2020  路  4Comments  路  Source: godotengine/godot

Godot version:

3.2.3 RC5

OS/device including version:

Windows 10

Issue description:

1 - Using tool script spawn node in the scene tree. It is visible in the viewport but not in the scene tree. It becomes invisible if the parent is turned invisible. I'd like to generate a scene with a tool script and save the scene. Or delete node it was unnecessarily generated.
2 - Tool script triggers _ready() method on opening scene in the editor. Meaning the ready method needs to be altered every time script using the scene needs to be opened, so it doesn't happen on opening. There needs to be a way to gate the _ready method for a time while in the editor (like callback _ready_editor( ) ) and not trigger logic that's made for the game runtime.

Steps to reproduce:

  1. Make a tool script.
  2. Script spawns a node via set get or in the _ready method (which gets called on the opening the scene in the editor)

Minimal reproduction project:

ToolSpawner.zip

archived editor

Most helpful comment

The owner must be set after the child is added.
image

All 4 comments

The owner must be set after the child is added.
image

This made me realy happy!
But is there a way to separate tool script in editor _ready?
Also if this spawning connects a signal, shouldn't the note show icon of connected signal? Or that is reserved to only connected in the editor Node tab?

But is there a way to separate tool script in editor _ready?

Engine.editor_hint

if Engine.editor_hint:
    #editor specific code here

Also if this spawning connects a signal, shouldn't the note show icon of connected signal? Or that is reserved to only connected in the editor Node tab?

You need to add CONNECT_PERSIST flag to your connection, e.g. connect("signal", object, "method", [], CONNECT_PERSIST)

That said, there is clearly no bug here. If you have any additional questions, use other community channels.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

testman42 picture testman42  路  3Comments

EdwardAngeles picture EdwardAngeles  路  3Comments

n-pigeon picture n-pigeon  路  3Comments

bojidar-bg picture bojidar-bg  路  3Comments

blurymind picture blurymind  路  3Comments