So, a create GUI in game engine, and need use callback's
cur time i use this code:
class SomeClass
{
void MyCallbackFuciton() {}
void Load()
{
GetWidget( "Start" ).AddEvent( "MyCallbackFuciton" );
}
}
c++:
r = en->RegisterObjectMethod(type,"void AddEvent( const string &)",asMETHOD( T, AddEvent), asCALL_THISCALL ); assert( r >= 0 );
void AddEvent( const std::string &_method )
{
asIScriptContext *ctx = asGetActiveContext();
asIObjectType *obj_type = ctx->GetEngine()->GetObjectTypeById( ctx->GetThisTypeId() );
// get method by name
funcId = obj_type->GetMethodByName( method.c_str() );
}
whether it is possible to make so?
class SomeClass
{
void MyCallbackFuciton() {}
void Load()
{
GetWidget( "Start" ).AddEvent( MyCallbackFuciton );
}
}
c++:
r = en->RegisterObjectMethod(type,"void AddEvent( func_id or int or asIScriptFunction or.. )",asMETHOD( T, AddEvent), asCALL_THISCALL ); assert( r >= 0 );
void AddEvent( int _funct_id or asIScriptFunction *_fucnt )
{
// ...
}
all sense in checking correctness at a compilation stage
i.e. this code work, but no correct GetWidget( "Start" ).AddEvent( "MyCallbackFuciton_ololo" );