Any in host classes
Hey
Sorry for not spinning off one of the existing "any" discussions, but GameDev wouldn't let me reply to them.
Anyway... I'd like to have an "any" member in a class defined in the host application (C++), and exposed to the script with RegisterObjectProperty. (Basically I want my script to be able to store user data in host objects.)
Any ideas on how to do that?
/Anders
You could have the class store a pointer to an asIScriptAny class and register it as a handle.
You could also have the class automatically initialize this handle in the constructor by calling
You may be able to register the any property as a reference to an any object. But I don't remember if I implemented support for that.
Regards,
Andreas
engine->RegisterObjectProperty("myclass", "any @user", offsetof(myclass,user));
You could also have the class automatically initialize this handle in the constructor by calling
int anyTypeId = engine->GetTypeIdByDecl(0, "any");this->any_obj = (asIScriptAny*)engine->CreateScriptObject(anyTypeId);
You may be able to register the any property as a reference to an any object. But I don't remember if I implemented support for that.
engine->RegisterObjectProperty("myclass", "any &user", offsetof(myclass,user));
Regards,
Andreas
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement