-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
Setter function of exported property only called when the value is different from its default #83375
Comments
This isn't because the setter isn't called for default, it's because the default value isn't stored in the scene so it isn't called when the scene is loaded Not a bug, but by design, you need to instead handle the default value manually if you need to detect it, relying on the default value being set isn't reliable and you shouldn't do it You should instead handle this in |
I realized this thing when exporting horizontal alignment of a child To solve this, on the |
Yes, that's to be expected You are expected to have your code be configured based on the default values, that's what them being default values means IMO |
So although I would like to use |
That's not a bug though you need to make sure that your script and scene is set up so it works correctly when used, you need to make sure your label has the same default as your property |
I understand, it's not a bug. You have to design the node from default values. This behaviour should be commented at docs at least. |
Sure this can be added to some of the documentation, unsure how to make it clearer though |
I opened the corresponding issue at docs. |
Closing in favour of godotengine/godot-docs#8246 |
Godot version
v4.1.2.stable.official [399c9dc]
System information
Godot v4.1.2.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1050 (NVIDIA; 31.0.15.3742) - Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz (8 Threads)
Issue description
The setter function of an exported property is only called when the value is different from its default.
I think it should be called even if its value is the same as the default one, because the setter function might contain logic considering both cases. If the setter is not called when initializing the class, it would be skipped, giving unexpected results.
Steps to reproduce
Attach this script to a
Control
and run the scene with different exported property values (default and not default):Minimal reproduction project
bug.zip
The text was updated successfully, but these errors were encountered: