Singletons in Godot aren't really ones, they are just nodes placed under the root of the tree. For example, it looks like this in a game:
- root (Viewport)
- AnAutoloadNode
- CurrentSceneRoot
- SomeSpriteInGame
- ...
You can see this when running a game and toggling Remote
on the scene tree editor.
The Godot editor is built like a game. Which means it also has a SceneTree with a root, so it can also have autoload nodes that you can place at the same location simply using get_tree().root.add_child(singleton_node)
from within your EditorPlugin (you also have to take care of removing it if your plugin gets destroyed).
Here is a simplified view how the Godot Editor scene tree looks like:
- root (Viewport)
- PlaceToAddYourSingleton
- EditorNode
- Lots of editor UI nodes
- EditedScene (Viewport)
- YourEditedScene
In Godot 3.0.x you won't be able to access singleton nodes by name (which is a special GDScript syntax sugar that is being added in 3.1), but as long as you have access to the tree, I believe you will be able to get your node from anywhere using get_node("/AnAutoloadNode")
.