Jump to content

[SOLVED] ExternClass as a Variable


photo

Recommended Posts

I am trying use this solution https://developer.un...-as-a-variable/ but got crash.

 

Reproduced on https://developer.un...&attach_id=1200 from https://developer.un...-uniginescript/ topic.

 

Add in C++

mydata testData;
testData.name = "Hello from C++";
engine->runWorld("helloStruct", Variable(TypeInfo(TypeID<mydata*>()), &testData));

Add in script

void helloStruct(mydata data) {
   log.message("%s\n", data.getName());
}

Link to comment

Please use the pushWorld()/popWorld() functions around your code:

mydata testData;
testData.name = "Hello from C++";
engine->pushWorld();
engine->runWorld("helloStruct", Variable(TypeInfo(TypeID<mydata*>()), &testData));
engine->popWorld();

Link to comment

This seems to be a so common "mistake" most probably supported by missing clear UNIGINE documentation and C++ examples on mandatory usage of engine->push/popWorld() /engine->push/popSystem() when calling script part from C++.

 

Suggestion:

 

documentation improvement and update of embedded code snippets to include engine->push/popWorld()/System() code

Link to comment
×
×
  • Create New...