ivan.cuevas Posted June 23, 2014 Posted June 23, 2014 Hi, for the following sample code: #include <samples/systems/common/systems.h> /************************************************************************\ * * AClass * ------ * \************************************************************************/ class WorldAClass { int a_val; WorldAClass(int a) { a_val= a;} }; /************************************************************************\ * * Global functions * ---------------- * \************************************************************************/ /* */ void update_scene() { while(1) { wait; } } /* */ void create_scene() { NodeDummy ndummy= new NodeDummy(); ndummy.setName("world_dummy"); engine.editor.addNode(class_remove(ndummy)); ndummy.setVariable(new WorldAClass(45)); return "plugin class id"; } I launch an editor plugin with the following code: /******************************************************************************\ * * Plugin * \******************************************************************************/ /* */ // This function should return your plugin namespace name. string getName() { return "FooPlugin"; } /* */ void init(string name) { aE3D::FooPlugin::init(name); } /* */ void shutdown() { aE3D::FooPlugin::shutdown(); } /* */ void update(int need_reload) { aE3D::FooPlugin::update(need_reload); } /* */ class EditorAClass { int p_v; EditorAClass(int v) { p_v= v;} }; /********************************************************************\ * * FooPlugin * --------- * \********************************************************************/ namespace aE3D::FooPlugin { using Unigine::Widgets; Window mainWnd; /* */ void init(string source) { NodeDummy ndummy= new NodeDummy(); ndummy.setName("plugin_dummy"); EditorAClass a= new EditorAClass(33); ndummy.setVariable(a); engine.editor.addNode(class_remove(ndummy)); } /* */ void shutdown() { ; } /* */ void update(int need_reload) { Node mynode= nodesGetNode(); if(mynode != NULL) { engine.message("mynode: %s", typeinfo(mynode)); log.message("var: %s", typeof(mynode.getVariable())); } } } Well, when I select "world_dummy" the engine reports me that node variable is a EditorManipulatorRotator :blink: , but when I select "plugin_dummy" engine shows node variable is an EditorAClass instance (correct) I need to create nodes and set its variable data with other user classes, so: What is the best way to interchange data between UnigineEditort plugin and World. Is this a bug? In that case, I will thank if Unigine team can supply a patch (or at least a workaround) because it's a critical issue for me. Best Regards, Iván.
silent Posted June 25, 2014 Posted June 25, 2014 Hi Iván, Thank you for detailed description. You can get access to your custom user classes only from the same scope (for example, if your user class is declated in editor script, only editor script can get access to it). So, this is not a bug. To transfer data between different scripts you can use setData/getData functions. If you need to transfer complex variables structure, you can pass XML formatted strings. Please, check the attached example, where setData/getData functions are used. test_data.zip How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
Recommended Posts