karim.salama Posted January 26, 2022 Posted January 26, 2022 Hello, In Unigine's Editor plugin implementation, there is no "update" function. So I made an update function which is executed on a thread which starts in init and terminates in shutdown. Apparently, nodes cannot be added to the world on a thread other that the main thread. Why? Is there a workaround for this? void add_dummy_to_selected() { auto dummy = Unigine::NodeDummy::create(); dummy->setShowInEditorEnabled(true); dummy->setOwner(false); if (Editor::SelectorNodes* snodes = Editor::Selection::getSelectorNodes()) { auto nodes = snodes->getNodes(); if (nodes.size() >= 1) nodes[0]->addChild(dummy); } } void add_dummy_with_thread() { std::thread thread = std::thread(&add_dummy_to_selected); thread.join(); } In the example above, using add_dummy_to_selected works, but add_dummy_with_thread doesn't. Thanks in advance
turbo Posted January 27, 2022 Posted January 27, 2022 Hello. You can use System Logic and World Logic to implement your own update func. I have attached the source code for example. I modified the source code of our MaterialsPlugin sample. Thanks MaterialsPlugin.h MaterialsPlugin.cpp 1 1
karim.salama Posted January 27, 2022 Author Posted January 27, 2022 Hi @turbo, Ok thank you. But why not use Editor Logic?
Recommended Posts