Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DenisComtesse | |
Old Version | Published before Godot 3 was released. |
I’m writing an editor plugin, and I’d like to be able to add a root node (or change the root node) for the currently edited scene.
Is this even possible from GDScript? Adding child nodes is working just fine, but how do I add a new root?
How are you doing it? I’m actually trying the same thing, but I’m kinda lost even looking at the current addon examples.
henriquelalves | 2016-05-20 08:59
Hm, can you be a little more specific? What exactly are you trying to do?
DenisComtesse | 2016-05-20 19:07
Well, so far I’m trying to implement a side-dock addon that can manipulate the main scene nodes; but for some reason, the side-dock node is not loading its own scripts. When I connect a “pressed” action of one of the dock buttons to the main control node script of the dock, the terminal gives me an error every time I click the button “The method called by the signal doesn’t exist” when it clearly exists on the script. I don’t think this is directly related to your problem, but I’m trying to understand when and where the addons are actually loaded on the engine, because it looks like it’s in a completely different place than the current Tree node scene.
As a side note (and something that maybe you can use), I was able to find the current “2D world” scene by using a recursive search on the “/root” node (so I could draw stuff directly on the 2D interface): Recursive search for viewport on Godot · GitHub
I wasn’t the author (it was someone who answered one of my questions here on the Q&A), but maybe you can use it to find the Node Tree scene and hack yourself in adding a root node?
henriquelalves | 2016-05-20 20:24
Can’t really say anything about your problem without seeing what you do in these scripts. Here’s how I do it:
I don’t connect any buttons within the “dock” scene, instead I just use the actual EditorPlugin script to write the functions and connect the buttons. This way I can use the buttons to call EditorPlugin functions more easily.
However, what you’re doing should work too, so I don’t quite know what you’re doing wrong.
DenisComtesse | 2016-05-22 07:59