f.reichl Posted April 10, 2019 Share Posted April 10, 2019 Hi all, I'm having issues loading nodes as references or layers into the scene through the C++ API. We are currently loading nodes into the World (in editor- and in release mode) like this: auto node = Unigine::World::get()->loadNode(path); Unigine::Editor::get()->addNode(node); I'd like to replace this to use either Node References or Node Layers instead, but I can't get it to work properly. What I tried was: auto node = Unigine::NodeReference::create(path); Unigine::Editor::get()->addNode(node->getNode()); This crashes somewhere in the Unigine internals on world update, it looks like the node pointer gets invalidated after "node" goes out of scope. Am I missing something that I need to do to have the Editor take over ownership of the reference? I can't find any method to add the node to the current world, even though I'd assume this needs to be done somehow... Also, is it possible to load nodes as References / Layers without adding them to the Editor? In the first snippet, I can simply omit the call to Editor::get()->addNode(), then the Node is present in the World but not visible in the editor. Link to comment
cash-metall Posted April 10, 2019 Share Posted April 10, 2019 59 minutes ago, f.reichl said: This crashes somewhere in the Unigine internals on world update, it looks like the node pointer gets invalidated after "node" goes out of scope Try use release() before add in Editor. auto node = Unigine::NodeReference::create("NodeDummy.node"); if (node) { node->release(); Editor::get()->addNode(node->getNode()); } 1 hour ago, f.reichl said: Also, is it possible to load nodes as References / Layers without adding them to the Editor? In the first snippet, I can simply omit the call to Editor::get()->addNode(), then the Node is present in the World but not visible in the editor. yes, you can use nodereference without Editor. But you have to destroy the nodes yourself. Link to comment
f.reichl Posted April 15, 2019 Author Share Posted April 15, 2019 Thanks, the release did the trick! Link to comment
Recommended Posts