-
-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to bind indexed properties #1182
Comments
The fix here is to either change Seeing as how this index has a magical default value of Let me know which is preferable and I'll be happy to make the pull requests for Godot and godot-cpp. |
Yep, for compatibility it will have to be a new function. If it would make the implementation simpler, you can have the old function call the new function. |
Alright, sounds good. I'll throw together some pull requests within the next day or two. |
Godot version
4.2-dev (f880892c3)
godot-cpp version
4.2-dev (749b0b9)
System information
Windows 11 (10.0.22621)
Issue description
In Godot itself you have the ability to bind a property with what's called an "index", which essentially just binds an integer (usually an enum value) to the property that will always be passed in as the first argument to its getter and setter functions. You typically do this using the
ADD_PROPERTYI
macro, as seen here.In godot-cpp there is an index parameter for
ClassDB::add_property
, but it seems that it's currently being discarded completely, along with the rest of the (seemingly unused)PropertySetGet
struct, as seen here. As far as I can tell this has been the case for as long as GDExtension has been a thing.Since the index is being discarded currently, it gets the default value of
-1
and leads to the binding of the property emitting errors sayingERROR: Invalid function for setter 'MyNode::my_setter for property 'my_property'.
The only workaround is to not use indexed properties, and instead create and bind a bespoke setter/getter method for each property.
Steps to reproduce
Add (and register) the following class in an extension of your choosing:
... and then run Godot from within a terminal/console, since the error message is only emitted into stderr when starting the editor, which should look something like this:
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: