Paul.Cechner Posted May 4, 2017 Share Posted May 4, 2017 We are transitioning our unigine script code to C++ - I would really like to be able to embed a C++ widget in a WidgetWindow that is managed within UnigineScript. Is there a way to pass a Widget created in C++ to UnigineScript code? Link to comment
alexander Posted May 5, 2017 Share Posted May 5, 2017 Hi, Paul! There is one way. Unfortunately, not directly.1) Create a C++ widget and attach it to the GUI: Gui::get()->addChild( yourCPPWidget->getWidget() );2) Call your UnigineScript method: Engine::get()->runWorldFunction( Variable("yourMethod") ); 3) In this method detach your C++ widget from the GUI: yourWidget = engine.gui.getChild( engine.gui.getNumChildren() - 2 ); // 2 - because last widget is the Console, not your widget Best regards, Alexander Link to comment
Paul.Cechner Posted May 5, 2017 Author Share Posted May 5, 2017 Hi Alexander, I might have over-complicated things in my question, I belatedly realised that I could just use: Variable v(interpreter, myCppWidget); // and myCppWidget = v.getWidget(interpreter); ... I can then pass this variable as an argument when invoking UnigineScript Thanks for your help, Link to comment
Recommended Posts