-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
default values for properties added by _get_property_list() #30440
Comments
I noticed that as well (v.3.2.3.stable.official). So I played around a little a bit and saw, that the inner workings would be ready to be able to revert properties that were added with the Example:
|
@Razoric480 (and anyone that is looking to add default values to custom properties, like me, from the future) # implement property_can_revert() and property_get_revert()
# assuming that we added "test_property" in property list and it has a custom getter/setter
func property_can_revert(property:String) -> bool:
if property == "test_property":
return true
return false
func property_get_revert(property:String): # -> Variant() type
return null # Here we may verify the property and what can be its default value Relevant information: godot/editor/editor_inspector.cpp Line 452 in 8f0208a
Just two observations:
Hope someone manages to open a PR that let you use null as default value and document those functions (wich I think are not exposed and we are just using dark magic) Relevant line to enable null as an option of default value: godot/editor/editor_inspector.cpp Line 496 in 8f0208a
|
- Added a method to set default values for properties See godotengine/godot#30440 (comment)
- Added a method to set default values for properties See godotengine/godot#30440 (comment)
I recently ran into this problem. I have a property who’s type is func property_get_revert(property):
if property == "overhead_texture":
return Reference.new() I think that an |
I think this issue is already solved? Mentioned methods are now exposed and documented |
As of now (3.1.1 stable) it's not possible to assign default values to properties added via _get_property_list(). My current workaround is to use the same variable and property name and set the default value on the variable, but this doesn't work for any variable that needs custom _set() code.
There's also the problem that you can't revert properties added by _get_property_list() back to their defaults in the inspector (the revert arrow doesn't show up).
It would be neat if it was possible to add a "default_value" field to the returned dictionary from _get_property_list().
The text was updated successfully, but these errors were encountered: