So I've gone through this doc article on how to create a basic editor plugin using GDScript and have made a few simple plugins. I've also developed a custom module in C++. What I was wondering is whether it's possible to write another editor plugin but using C++ instead without modifying the Godot's source.
It seems like I've already figured out how to write an editor plugin by looking how other built-in plugins are implemented as in here.
In editor_node.cpp I discovered that plugins are registered during initialization of EditorNode
, for instance:
add_editor_plugin(memnew(VisualShaderEditorPlugin(this)));
So it appears to me that I could use EditorNode
singleton and add my plugin like this within a module:
EditorNode *en = EditorNode::get_singleton()
en->add_editor_plugin(memnew(AnlNoiseEditorPlugin(en))
The problem is that I don't know when and where to do this. I've tried doing so in register_types
:
void register_my_module_types() {
ClassDB::register_class<MyModule>();
EditorNode *en = EditorNode::get_singleton();
en->add_editor_plugin(memnew(MyModuleEditorPlugin(en)));
}
And en
is NULL
here because it seems like EditorNode
is not even initialized yet, so I wonder what to do now.