godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Can't bind user-defined type if it doesn't inherit from Object

Open nongvantinh opened this issue 3 years ago • 4 comments

Assume that I have a class which do not inherit from anything

class UserDefineType
{
// Some properties.
};

There is no way that I can ADD_PROPERTY to use it in GDScript/C# as it requires PropertyInfo must be one of the variant type.

nongvantinh avatar Feb 10 '22 16:02 nongvantinh

@nongvantinh Which Godot version are you using?

Calinou avatar Feb 10 '22 17:02 Calinou

I'm testing in both Godot 3.4.2 and 4.0 using 3.x and master. If there is some way it should mention some where. As a user I have no glue.

nongvantinh avatar Feb 10 '22 23:02 nongvantinh

I am misunderstanding this use case, It is not the way Godot works. I must inherit from Reference or its derived class just like C# to make it work. It seems like this is also the way Godot Module works.

We should mention this somewhere in the usage document.

nongvantinh avatar Feb 11 '22 03:02 nongvantinh

I must inherit from Reference or its derived class just like C# to make it work.

You can probably inherit from Object too (if you don't need reference counting).

Calinou avatar Feb 11 '22 08:02 Calinou