Jump to content

[SOLVED] run class member function from c++


photo

Recommended Posts

Hi

I have an external class (defined on c++ side).  For example

class Foo : public Base 
{
   public:
	
   Foo() 
   {
      Log::warning("Foo::Foo(): called\n");
   }

   ~Foo() 
   {
      Log::warning("Foo::~Foo(): called\n");
   }
};

And another class defined on Unigine script side. TIhis is subclass of Foo.

class Bar : Foo 
{
   Bar() : Foo()
   {
      log.message("Bar called\n");
   }
   void info()
   {
      log.message("info called\n");
   }
}

Bar makeClass()
{
    Bar b = new Bar();
    return b.extern;
}

Class Foo is defined as extern on c++ side using MakeExternClass function.  And now my stupid question. Is any way to call method "info" from c++ side ?

Class Bar is created by calling from c++

Engine *e = Engine::get();
Variable ret = e->runWorldFunction(Variable("makeClass"));

Code is simplified, no errors etc.

Link to comment
×
×
  • Create New...