How to solve this communication problem?
In my map editor, I have a bunch of buttons in the UI that reside inside a MenuBar scene, and I have to connect those buttons' functionalities to the editor node. The problem is, to make the UI's complexity more manageable, I made some UI nodes packed scenes. The MenuBar is a packed scene and is inside another packed scene in the UI hierarchy, so signals can only be connected to that scene's root, and that blocks their communication with both the main UI node and the editor node itself.
I'm not sure how to tackle this. I can only think of two ways, and I'm not so happy about either of them.
- make the MenuBar and its parent packed scenes relay signals through each other up the chain to the main UI node, which can then relay to the editor node (which is down the hierarchy again, inside a viewport).
- have the editor node register itself in a global list of objects in an autoload (I have this in a
corescript), and then the buttons can do something like
core.call_object("editor node", "undo").
Is there a better way to work around this?