Jump to content

[SOLVED] Pass C++ widget handle to Unigine Script?


photo

Recommended Posts

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

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

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
×
×
  • Create New...