Jump to content

[SOLVED] extern class in multi plugins


photo

Recommended Posts

Posted

hi, i added custom class in one plugin and in another plugin i use this class, in first plugin Unigine script can send class instance by Variable, in second - ("can't convert extern class to class")

 

plugin1.h:

class A_class {
public:
    A_class();
    void test();
};

plugin1.cpp

A_class::A_class() {}
A_class::test() {}

A_class* ac = NULL;
void setAC(Variable v) {
   ac = VariableToType<A_class*>(Interpreter::get(), v).value;
}

//--------- UNIGINE export
Interpreter::addExternFunction("setAC",MakeExternFunction(&setAC));
//class export
ExternClass<A_class> *a = MakeExternClass<A_class>();
a->addConstructor();
a->addFunction("test", &A_class::test);
Interpreter::addExternClass("A_class", a);

plugin2.cpp

#include "plugin1.h"

A_class* ac = NULL;
void setAC(Variable v) {
   ac = VariableToType<A_class*>(Interpreter::get(), v).value;
}

//--------- UNIGINE export
Interpreter::addExternFunction("setAC2",MakeExternFunction(&setAC));

in UNIGINE script

A_class ac = new A_class();
setAC(ac);  //OK
setAC2(ac); //Variable::getExternClassObject(): can't convert extern class to class A_class*
 

what i must do to fix it?

 

 

 

 

 

 

  • 2 weeks later...
Posted

Hey Sergey,

 

I think it's better to keep all API that's related to some functionality in one place. Also, check loading order of your plugins as it may be the trouble in your case.

×
×
  • Create New...