Amerio.Stephane Posted September 12, 2018 Share Posted September 12, 2018 Hello, engine.editor.getNodeByName("xxx"); does not return the NodeReference to my existing xxx NodeReference in my scene. If I do a loop through all nodes, then the NodeReference is correctly found. forloop(int i = 0; engine.editor.getNumNodes()) { Node node = engine.editor.getNode(i); Node target_node = node; if(target_node.getType() == NODE_REFERENCE) { NodeReference reference = node_cast(target_node); target_node = reference.getReference(); if (target_node.getName()=="xxx") log.message("%s\n",target_node.getName()); // The node is correctly found } } Node xxx = engine.editor.getNodeByName("xxx"); log.message("%s\n",xxx.getName()); // xxx is null: the node is not found Is it a bug or did I miss something ? Link to comment
andrey-kozlov Posted September 13, 2018 Share Posted September 13, 2018 Hello, Snipets are not equal. The first one searching for the root node of NodeReference and the second one can only find NodeReference itself but not its content. If NodeReference itself has known name it can be found by editor and then you can get its root node. Link to comment
Amerio.Stephane Posted September 13, 2018 Author Share Posted September 13, 2018 Here is a step by step repro: - create/primitive/box and rename it "xxx" - right-click/Create a NodeReference (named "xxx") -run the previous script in a WorldExpression (add the line #include <core/scripts/utils.h> at the top), enclosed in "{ }" -result is: Quote xxx <<< printed by the log.message in the loop ExternClass::run_function(): object is NULL in "class Node * __ptr64" class <<< printed by the getNodeByName So getNodeByName can't find nor the NodeReference's Reference node, nor the Node corresponding to the NodeReference. Link to comment
andrey-kozlov Posted September 13, 2018 Share Posted September 13, 2018 I've reproduced this behaviour. World reloading fixes it so it shouldn't be an issue at runtime. I believe that's an editor bug that NodeReference can't be found by name right after creation like other types of node. Link to comment
Amerio.Stephane Posted September 13, 2018 Author Share Posted September 13, 2018 Agreed. If I drop the ".node" file in the scene, then both works. But if I "Edit" the NodeReference and then click "Cancel" or "Apply" then the getNodeByName doesn't work any more. The problem is not for runtime, but during the development time, in editor ! Because it breaks the workflow, I think it should be fixed. Link to comment
silent Posted September 13, 2018 Share Posted September 13, 2018 Amerio, Sure thing. We will try to fix this in the upcoming SDK update. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts