Jump to content

Editor::Selection::instance() returns false in init()


photo

Recommended Posts

Hi,

In a class deriving from Unigine::Plugin, there is an init function with the following code :

QObject::connect(Editor::Selection::instance(), &Editor::Selection::changed, &on_selection_changed);

Apparently, Editor::Selection::instance() returns nullptr.

I have tried changing Unigine::Plugin into Editor::Plugin, (by the way, what's the difference?) Editor::Selection::instance() still returns nullptr, I get the following error and the editor crashes.

EnginePlugins::addPlugin(): "test_plugin" plugin compilation flags (Double-Release) do not match the engine ones (Double-Debug)

Am I missing something?

Thanks in advance

Link to comment

Unigine::Plugin is for extending Engine functionality. Editor::Plugin is for Editor.
These plugins have different life cycles. There are steps of Editor's initialization:

  • You launch Editor.
  • It loads and initializes Engine.
  • Engine loads and initializes a lot of things and Engine's plugins too (Unigine::Plugin).
  • Then Editor initializes a lof of its own subsystems and Editor::Selection subsystem too.
  • And at the end Editor initializes its plugins (Editor::plugins).
Quote

Editor::Selection::instance() returns nullptr

You call this function when Editor didn't initialize its subsystems yet.

Quote

EnginePlugins::addPlugin(): "test_plugin" plugin compilation flags (Double-Release) do not match the engine ones (Double-Debug)

I suspect you added your "test_plugin" plugin by using this command "-extern_plugin test_plugin" to launch Editor. This command is only for Engine and only for loading Engine plugins.

You just need to copy your plugin file here:
%project%/bin/editor — for Release build;
%project%/bin/editor_debug — for Debug build;

Please look at this link for more information:
https://developer.unigine.com/en/docs/future/editor2/extensions/custom_plugin?rlang=cpp#plugin_run

To build a good Editor's plugin you should enable using of the Qt Meta-Object compiler (moc). It's necessary to inject a meta information of your plugin class into your plugin file. In CMake it's done by using one command:

set(CMAKE_AUTOMOC TRUE)    # Enable automatic handling for moc.

 

  • Thanks 1
Link to comment

Ok thanks this is much clearer now.

Yes, you are right, I was using the argument -extern_plugin.

It would be nice if the engine can take the plugin folder (.../bin/editor) as an argument.

Thank you

Link to comment
×
×
  • Create New...