-
-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can GDVIRTUAL_BIND and GDVIRTUAL_CALL be added to the lib? #1072
Comments
I see BIND_VIRTUAL_METHOD exists. |
These infomations are added to ClassDB, but not be used in godot editor, I guess. |
GDCLASS macross has inside it:
so you can't add this function in your class to bind your |
I'm dont't not the function of this template method. Ignoring the call order, for your custom virtual methods, you can bind them in
As you can see. it is added to Currently, you can use |
Thank you. It does call function in the script. |
But it turns out than you cant call function ,declared this way, from GDScript. It cant find it. |
I think you should call |
Hi @Daylily-Zeleen @RonYanDaik , // in gdextension
struct BaseFeature : Resource{ // registered with ClassDB::register_class<BaseFeature >(true); for virtual
GDCLASS(BaseFeature,Resource)
virtual void my_function() {} // Will be overwrited in gdscript.
static void _bind_methods(){
ClassDB::bind_method(D_METHOD("my_function"), &BaseFeature ::my_function);
}
}; my goal is to have an array of them, and call them like this in gdextension : for(auto i = 0; i < array_of_features.size(); ++i )
{
BaseFeature * f = Object::cast_to<BaseFeature >(array_of_features[i]);
f->my_function(); // Call the overrided function in a gdscript.
} For now it only call the base version of the functions, but I created a new resource from a children class. class_name MyFeature extends BaseFeature
func my_function(): # I has the sign that it override a function
print("hello world") My code is very data intensive, but I would like to override a few functions in gdscript for configuration and let the bulk of the work be done in c++. Thank you, any help is useful |
1 similar comment
Hi @Daylily-Zeleen @RonYanDaik , // in gdextension
struct BaseFeature : Resource{ // registered with ClassDB::register_class<BaseFeature >(true); for virtual
GDCLASS(BaseFeature,Resource)
virtual void my_function() {} // Will be overwrited in gdscript.
static void _bind_methods(){
ClassDB::bind_method(D_METHOD("my_function"), &BaseFeature ::my_function);
}
}; my goal is to have an array of them, and call them like this in gdextension : for(auto i = 0; i < array_of_features.size(); ++i )
{
BaseFeature * f = Object::cast_to<BaseFeature >(array_of_features[i]);
f->my_function(); // Call the overrided function in a gdscript.
} For now it only call the base version of the functions, but I created a new resource from a children class. class_name MyFeature extends BaseFeature
func my_function(): # I has the sign that it override a function
print("hello world") My code is very data intensive, but I would like to override a few functions in gdscript for configuration and let the bulk of the work be done in c++. Thank you, any help is useful |
Just use 'call()' both c++ and gds. |
Looks like these two macroses are used by godot to call gdscript methods.
Can these two be added into godot-cpp?
The text was updated successfully, but these errors were encountered: