Edit 4.3.x
Since 4.3.x you can create your virtual methods. These are the steps:
In the header file, include those headers:
#include <godot_cpp/core/binder_common.hpp>
#include <godot_cpp/core/gdvirtual.gen.inc>
Now define you virtual method in the class’ declaration. Note, there are many macros to do it, example:
/// if the macro ends with the "RC" suffix, the virtual method will returns a value,
/// which is the first argument of the macro, followed by the virtual name method
/// and the arguments expected by the macro name itself
GDVIRTUAL1RC(float, _my_virtual_method_name, Array);
/// if the macro does not end with that suffix, then the first
GDVIRTUAL2(_another_virtual_method_name, Array, double);
Then into your implementation, inside the static method _bind_methods
, use these macros
GDVIRTUAL_BIND(_my_virtual_method_name, "argument_0_name")
GDVIRTUAL_BIND(_another_virtual_method_name, "argument_0_name", "argument_1_name")
Godot Version
4.2.x
Question
Hello, I am porting my extension to c++ and I need to mark several functions as virtuals in gdscript.
What I tried
I tried using the BIND_VIRTUAL_METHOD but it does not mark my method as virtual in gdscript.
If I try to create an empty method in the header file called for example _foo
, then bind it in the static method _bind_methods
as
BIND_VIRTUAL_METHOD(MyClass, _foo)
it does not appear in the methods listed by gdscript.
Could somebody give me a hint? Thanks in advance