Support virtual methods like '_process' in sub classes.
NathanWarden opened this issue · 8 comments
I think it would be very beneficial to be able to place a Godot virtual method into a sub/base class.
For instance:
public class MyBaseClass : Spatial
{
void _process(float delta)
{
GD.print("I will only be called if I'm the attached script!");
}
}
public class MySubClass : MyBaseClass
{
// _process will not be called on MyBaseClass
}
Does this not work already? BTW, it's _Process
:
public override void _Process(float delta)
{
}
It doesn't seem to be working with uppercase _Process, but putting lowercase "void _process(float delta)" into the class that you're attaching to a node works, but only if it's on the exact class you attach.
For instance:
public override void _Process(float delta)
{
Debug.Log("I'm not working...");
}
but,
public void _process(float delta)
{
Debug.Log("Working...");
}
Fixed by 9b97100
It should also warn you in debug builds when you declare the snake_case version of a Godot API method. e.g.:
WARNING: fetch_methods_with_godot_api_checks: Method `void _process(single)` should be `void _Process(single)`. In class `TheNamespace.TheClass`.
At: modules/mono/mono_wrapper/gd_mono_class.cpp:137.
@neikeq It looks like that was a step in the right direction, but unfortunately didn't fix it. I'll make an example project and probably a video to go along with it soon :)
In summary, it now doesn't even see a sub-class if the process method is on the base class. It dies with the error "Can't find res://", or something like that. I checked last night and don't remember the exact wording. I'll get back with more for you to work with.
Thanks again for all your hard work!
Can you upload an example project?
@neikeq Here's a zip file with both the project, in a folder called "GM" (for GodotMono), and a recording explaining what the issue is.
https://drive.google.com/open?id=0B8iCxych7qVBS2FtbWhnaVJ3Tk0
Thanks a bunch!
This time for sure.
Yes, fixed... thank you!