godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.71k stars 575 forks source link

Properties are not inherited #324

Open rainerdeyke opened 5 years ago

rainerdeyke commented 5 years ago

I have two GDNative classes registered, A and B, where B inherits from A. When using class B in the Godot editor, the properties from class A do not show up in the node editor.

`class A : public Node { GODOT_CLASS(A, Node); ... int a = 0; static void _register_methods() { // This property does not show up on instances of class B. godot::register_property("base/a", &A::a, 0); } };

class B : public A { GODOT_CLASS(B, A); ... int b = 0; static void _register_methods() { godot::register_property("base/b", &B::b, 0); } }; `

BastiaanOlij commented 5 years ago

Try using GODOT_SUBCLASS instead of GODOT_CLASS for class B

Philosopho commented 4 years ago

Hi, was this resolved? I am trying to do the same and no inheritance is happening. I am using GODOT_SUBCLASS for class B. I put a godot::Godot::print("Hello, world); statement for the init method of class A and nothing is printed in the editor. Thanks!