karim.salama Posted December 4, 2020 Posted December 4, 2020 Greetings, Say we have a custom class called Foo, which has managed Unigine pointers to another custom class called Bar. So, here is Foo's definition for now : class Foo { Unigine::Ptr<Bar> m_bar; public: Foo() = default; void setBar(Unigine::Ptr<Bar> ptr){ m_bar = bar; } } Now, when I try to add this implementation to the Unigine interpreter, I use the following code : Unigine::ExternClass<Foo>* fooClass = Unigine::MakeExternClass<Foo>(); fooClass->addConstructor(); fooClass->addFunction<Foo, void, Unigine::Ptr<Bar>>("setBar", &Foo::setBar); Unigine::Interpreter::addExternClass("Foo", fooClass); I get a compile error saying that 'release_ptr' is not a defined member of Foo. So, I defined 'static void release_ptr(Foo* p){ delete p; }' in the Foo class. Now I get a "'type cast': cannot convert from 'void*' to 'Type' " in UnigineInterpreter.h. Any ideas on how to solve this error? Thanks in advance
silent Posted December 7, 2020 Posted December 7, 2020 Hi Karim, There is no Unigine::Ptr in UnigineScript. Also it's not clear how you exposed Bar class. You can check all the possible ways of doing that in the following sample: <SDK>\source\samples\Api\Scripts\Classes. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
karim.salama Posted December 7, 2020 Author Posted December 7, 2020 Hi silent, Ok, I changed my managed class implementation according to the sample and now it works. Thank you.
Recommended Posts