You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
can GDVIRTUAL_BIND and GDVIRTUAL_CALL be added to the lib? #1072
so you can't add this function in your class to bind your virtuals. Maybe we can create another macros without declared register_virtuals in it?
I'm dont't not the function of this template method.
It seem do nothing form parent class to child class recursively, and just be called after _bind_methods.
Ignoring the call order, for your custom virtual methods, you can bind them in _bind_methods directly.
As you can see. it is added to virtual_methods, so the infomation of custom virtual methods are existed in ClassDB. Just not be used in Document( to refer) and LSP( to code hint).
Currently, you can use Object::call() instead of GDVIRTUAL_CALL.
I don't know there has a better way or not.
Hi @Daylily-Zeleen@RonYanDaik ,
I need more detail on the workaround you mentioned. I'm want to create a plugin that allows users to override my methods in gdscript, but calling those function in gdextension.
// in gdextensionstructBaseFeature : Resource{ // registered with ClassDB::register_class<BaseFeature >(true); for virtualGDCLASS(BaseFeature,Resource)
virtualvoidmy_function() {} // Will be overwrited in gdscript.staticvoid_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_nameMyFeatureextendsBaseFeaturefuncmy_function(): # I has the sign that it override a functionprint("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++.
Hi @Daylily-Zeleen@RonYanDaik ,
I need more detail on the workaround you mentioned. I'm want to create a plugin that allows users to override my methods in gdscript, but calling those function in gdextension.
// in gdextensionstructBaseFeature : Resource{ // registered with ClassDB::register_class<BaseFeature >(true); for virtualGDCLASS(BaseFeature,Resource)
virtualvoidmy_function() {} // Will be overwrited in gdscript.staticvoid_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_nameMyFeatureextendsBaseFeaturefuncmy_function(): # I has the sign that it override a functionprint("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++.
Activity
RonYanDaik commentedon Mar 23, 2023
I see BIND_VIRTUAL_METHOD exists.
Can we somehow use it with custom classes creating custom virtual functions?
Daylily-Zeleen commentedon Mar 27, 2023
These infomations are added to ClassDB, but not be used in godot editor, I guess.
RonYanDaik commentedon Apr 13, 2023
GDCLASS macross has inside it:
so you can't add this function in your class to bind your
virtuals.Maybe we can create another macros without declared
register_virtualsin it?Daylily-Zeleen commentedon Apr 13, 2023
I'm dont't not the function of this template method.
It seem do nothing form parent class to child class recursively, and just be called after
_bind_methods.Ignoring the call order, for your custom virtual methods, you can bind them in
_bind_methodsdirectly.BIND_VIRTUAL_METHODcallClassDB::bind_virtual_methodAs you can see. it is added to
virtual_methods, so the infomation of custom virtual methods are existed inClassDB. Just not be used in Document( to refer) and LSP( to code hint).Currently, you can use
Object::call()instead ofGDVIRTUAL_CALL.I don't know there has a better way or not.
RonYanDaik commentedon Apr 13, 2023
Thank you. It does call function in the script.
RonYanDaik commentedon Apr 26, 2023
But it turns out than you cant call function ,declared this way, from GDScript. It cant find it.
Daylily-Zeleen commentedon Apr 26, 2023
I think you should call
call("virtul_method_bind_in_cpp")in GDScript, too.Remi123 commentedon May 9, 2023
Hi @Daylily-Zeleen @RonYanDaik ,
I need more detail on the workaround you mentioned. I'm want to create a plugin that allows users to override my methods in gdscript, but calling those function in gdextension.
my goal is to have an array of them, and call them like this in gdextension :
For now it only call the base version of the functions, but I created a new resource from a children class.
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
Remi123 commentedon May 9, 2023
Hi @Daylily-Zeleen @RonYanDaik ,
I need more detail on the workaround you mentioned. I'm want to create a plugin that allows users to override my methods in gdscript, but calling those function in gdextension.
my goal is to have an array of them, and call them like this in gdextension :
For now it only call the base version of the functions, but I created a new resource from a children class.
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
Daylily-Zeleen commentedon May 9, 2023
Just use 'call()' both c++ and gds.