ataylor Posted November 3, 2015 Posted November 3, 2015 I am trying to export to UnigineScript multiple classes (with different names of course) that are tied to the same actual C++ class. App compiles but gives errors on world load Interpreter::addExternClass(): "foo" class is already defined If I try to use this class in UnigineScript: Interpreter::parse(): unknown token "foo" Is there a way to accomplish this without creating a new C++ class?
maxi Posted November 4, 2015 Posted November 4, 2015 Hi Adam, you can do it like this: ExternClass<NameOfCPlusPlusClass> *instance = MakeExternClass<NameOfCPlusPlusClass>(); Interpreter::addExternClass("ScriptClassName",instance); ExternClass<NameOfCPlusPlusClass> *instance2 = MakeExternClass<NameOfCPlusPlusClass>(); Interpreter::addExternClass("ScriptClassName2",instance2);
ataylor Posted November 5, 2015 Author Posted November 5, 2015 Thanks, I should have thought to try that.
ataylor Posted November 10, 2015 Author Posted November 10, 2015 Sorry for delayed response -- I have been away from work. maxi, the example you gave matches my current implementation. Two separate ExternClass<foo> pointers are created, each passed to Interpreter::addExternClass with separate names. This results in the errors I initially posted, with the Interpreter failing to register the second one claiming it has already been defined. Should I submit a test scenario?
silent Posted November 11, 2015 Posted November 11, 2015 Hi Adam, Small test sample with reproduction will surely help us in our investigation :) Could you please provide it (with small instruction how to build)? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN
ataylor Posted November 11, 2015 Author Posted November 11, 2015 Here you go. Build with Visual Studio 2013 copy resulting PluginTest.DLL into bin directory of existing Unigine project add "PluginTest" to extern_plugin setting in Unigine project's launcher or in system config Launch Unigine project Interpreter::addExternClass(): "fooAgain" class is already defined fooAgain class is thereafter unavailable to UnigineScript. PluginTest.zip
maxi Posted November 12, 2015 Posted November 12, 2015 Hi Adam, Sorry for the wrong answer. Indeed, you can't add two extern classes with the same typeinfo. You need to reorganize your code logic in some way.
Recommended Posts