There are a few things you need to know about what's actually happening:
When you switch tabs, Godot removes your scene from the scene tree. but it's still there, the nodes are not destroyed, so there is no reason to call _ready
again to reload things a second time, at least not by default.
When you switch back, Godot then re-adds your scene to the tree.
You can detect this by implementingt the _enter_tree
and _exit_tree
methods, which will get called when this happens.
Only catch to be aware, is that _enter_tree
will also get called before the first _ready
.
Finally, when you close the tab and reopen it, Godot does remove AND delete your nodes, so that's why when you reopen the scene, it of course calls _ready()
because Godot reloads it entirely.
If you really want _ready()
to be called again, you can request it with request_ready()
: https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-request-ready
Note, if you use _ready()
to spawn child nodes, you may not want it to be called again, because you'll end up creating the same nodes again.