-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Make property_*_revert
methods multilevel and expose them for scripting
#64334
Make property_*_revert
methods multilevel and expose them for scripting
#64334
Conversation
3a7236d
to
af87d14
Compare
af87d14
to
b40ef7f
Compare
Seems to fail on some |
Is there a reason for this to be implemented in |
It is because of the special multilevel call rules, yes. Seems to be the only way to do it in Object with all that boilerplate, and well, nothing in Object uses GDVIRTUAL for whatever reason. I can try hooking it up in CSharpInstance. |
b40ef7f
to
cfcf498
Compare
Okay, I followed the |
cfcf498
to
df74832
Compare
What I meant is that the implementation should call // Object
public virtual bool _PropertyCanRevert(StringName property)
{
return false;
}
// A inherits Object
public override bool _PropertyCanRevert(StringName property)
{
if (property == "foo")
return true;
return base._PropertyCanRevert(property);
}
// B inherits A
public override bool _PropertyCanRevert(StringName property)
{
if (property == "test_me")
return true;
return base._PropertyCanRevert(property);
} |
What about the existing multilevel methods like get_property_list? I got what you meant, but it seemed wrong to make these methods an exception when their related method is implemented manually, and so is every other Object method that is similarly exposed (set, get, notification). That's what I implied with "parity". |
godot/modules/mono/csharp_script.cpp Lines 1820 to 1831 in 2e24b76
It always stops after calling the first method it finds. BTW, just calling |
df74832
to
07ec138
Compare
Ah, right, that's why there is a break. I can see how you plan to improve the code in the .Net 6 PR, it all makes sense now. I think it should be correct now. Let me know if it can be improved. Edit: Well, I guess it's not correct since it fails to compile. Can't call a non-const method from a const method. I'm open to suggestions from a more experienced C++ developer. Worst case, I can revert this change and add |
I would try adding |
Wouldn't I need to change it through the inheritance chain in every base class it overrides too? It looks like it, and I don't think I can do that. I think being a generic call method, it cannot be expected to not mutate anything in every implementation. Edit: The push below doesn't change anything meaningful, it will still fail to compile. |
07ec138
to
f447504
Compare
Just tried adding
|
f447504
to
980f5f3
Compare
Yeah, you basically get a method signature mismatch with the base method. Changes done, restored the methods to their previous state, but with a break if the (script) method is ever defined. |
seems good to me |
Alright, I'll PR an update for |
Lesgo! |
Closes #43078. These methods used to be hidden inside of the Inspector logic, though some classes implemented and exposed them to the user (for no particular purpose, since they were exposed just because they were registered with
ClassDB
and users couldn't do anything meaningful with them).However, users could still use them, if they knew about them. This makes them officially a part of
Object
, exposed to API, and multilevel to boot, so that classes can extend each other instead of replacing each other.You can use them like this now:
I implemented the necessary core logic for GDScript and C#, but I would appreciate assistance with VisualScript, unless we no longer care about it due to recent changes.
Edit: I'm not sure if ML calls exist in VisualScript. I guess it's okay to leave it as is for now.