karim.salama Posted December 6, 2021 Posted December 6, 2021 (edited) Hi, I'm currently porting a custom tool from the old editor (deprecated) to the new one. In this tool there is a feature which added a node to the world using the following UnigineScript code : Creator::set_node(node,"editor/gui/node_reference.png"); What is the equivalent in C++ for the new editor? Thanks Edited December 6, 2021 by karim.salama
victor Posted December 6, 2021 Posted December 6, 2021 Hello, Please look at this C++ code, it's some equivalent for Creator::set_node: #include <editor/Actions.h> #include <editor/Selection.h> #include <editor/Selector.h> void add_node_dummy() { NodeDummyPtr node = NodeDummy::create(); // By using Undo::begin() and Undo::end() it's possible to group actions. For example, create and select a new node at once. Editor::Undo::begin(); Editor::Undo::apply(new Editor::CreateNodesAction(node)); // Ask Editor to select a new created node. Editor::SelectionAction::applySelection(Editor::SelectorNodes::createObjectsSelector({ node })); Editor::Undo::commit(); } 1 1
karim.salama Posted December 6, 2021 Author Posted December 6, 2021 Ok thanks, I will try this. By the way, I couldn't find the CreateNodesAction in the current documentation : https://developer.unigine.com/en/docs/2.14.1/api/editor/class_editor_1_1_action.html
fox Posted December 6, 2021 Posted December 6, 2021 Hi Karim, Please check out the new version of docs: https://developer.unigine.com/en/docs/future/api/editor/class_editor_1_1_create_nodes_action.html There is no CreateNodesAction action in 2.14.1.1, it is only available starting from 2.15. Thanks!
karim.salama Posted December 6, 2021 Author Posted December 6, 2021 @victor Ok, this works. But is the node gets added to the world directly. Is there anyway I can wait for the user to place the newly created node in the world, or press esc to cancel? @fox Ok, I will take a look. And yes I am using 2.15-beta. Thanks
silent Posted December 6, 2021 Posted December 6, 2021 Quote Is there anyway I can wait for the user to place the newly created node in the world, or press esc to cancel? Could you please tell how it was done in your pervious plugin implementation? How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
karim.salama Posted December 6, 2021 Author Posted December 6, 2021 @silent It was done using the following UnigineScript code : #include <editor/editor.h> Creator::set_node(node,"editor/gui/node_reference.png");
karim.salama Posted December 7, 2021 Author Posted December 7, 2021 I guess it's not possible right now in 2.15-beta, but it would be very nice to have this in the 2.15 release.
victor Posted December 8, 2021 Posted December 8, 2021 Hi, Quote it would be very nice to have this in the 2.15 release. Yes, it will be possible. It's some code snippet: #include <editor/ViewportManager.h> NodeDummyPtr dummy = NodeDummy::create(); ::Editor::ViewportManager::placeNodes({dummy}); 1
Recommended Posts