Jump to content

Creating custom nodes in the editor


photo

Recommended Posts

Posted (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 by karim.salama
Posted

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();
}

 

  • Like 1
  • Thanks 1
Posted

@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

Posted
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:

Posted

@silent It was done using the following UnigineScript code :

#include <editor/editor.h>
Creator::set_node(node,"editor/gui/node_reference.png");
Posted

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.

Posted

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});

 

  • Thanks 1
×
×
  • Create New...