-
-
Notifications
You must be signed in to change notification settings - Fork 225
Engine APIs with nullable parameters should accept Option<Gd<T>>
, but currently require Gd<T>
#156
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
Comments
Good catch! Yes, the object parameters should possibly be generic -- conceptually something like |
Is |
Yes. You're right, |
Option<Gd<T>>
, but currently require Gd<T>
I currently ran into a panic related to this issue when using surface tool. It looks like some work has been done to add extended parameters through the ExCommit type, but it currently throws an exception. I'm assuming it's just because it's a WIP? EDIT: let mut mesh: Gd<ArrayMesh> = st.call("commit".into(), &[]).to(); |
currently these just don't work properly if the default argument is null. but you can use the |
Uh oh!
There was an error while loading. Please reload this page.
[Edit bromeon]
If you come here because of an error message in gdext, that error message is correct. You likely encounter an API which is supposed to accept
null
arguments, but has aGd<T>
parameter declared -- so it's not possible to passnull
.Possible workaround: use
Object::call()
withVariant::nil()
.Issue #494 tracks a similar problem, but applied to virtual functions (the
I*
traits) instead ofgodot::engine
API.That one cannot be worked around currently.
Original title of this issue was:
Original message
In the GDScript docs for PhysicsBody3D, there is:
As you can see, the 3rd argument has a default null value. Rust does not allow nulls, and uses Option instead.
However, in the generated Rust function, it (IMO incorrectly) requires a Gd value that needs to be non-null.
The collision argument should be an Option so that it can take a None value. Otherwise, there is no known way to use the default arguments. This issue is related to #155
It's also likely that similar codegen issues exist in many other APIs.
The text was updated successfully, but these errors were encountered: