-
Notifications
You must be signed in to change notification settings - Fork 7
Added a new signal property_changed. Sent when a value is changed in the object inspector #5
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
base: master
Are you sure you want to change the base?
Conversation
…the object inspector
|
I'm sorry I don't understand exactly what this is for. Can you explain more? Or give me an example. |
|
Sure! When you edit a property value in the inspector, it triggers a "OnPropertyChange" signal. For example, in my case, I wanted to call queue_redraw() only when a certain value was changing. I have some custom "Draw" overrides and I don't want to call it every frame, so by registering a signal to the object_inspector, I'm notified when someone changes the value. I can then call the redraw. |
|
Also, an improvement that could be made is to send the previous and current value as parameter. |
|
If we're talking about a class object, why not use a setter for that? @export var some_value: int = 0:
set = set_some_value
func set_some_value(new_value: int) -> void:
if some_value == new_value:
return
some_value = new_value
if some_value == 42:
queue_redraw() |
|
Or are you using this for a custom object of class |
|
Ok, I'll try again to explain again :)
You already have a signal for when you set an object, which is cool. Now I've added another signal for when a value has changed on that object. So you don't need to add code for each setter to set some kind of "global" variable that your object has changed. With that, it can handle everything, even objects that you don't necessarily have control on it. Or event adding more code/logic on game objects. In my use case, the main screen has the object inspector. There are different object types on the screen. So, when I receive a signal, I call the queueRefresh only on the currently selected object. And for all my object types, I don't need to add the snippet you have provided. And if I want to do something else later on, I just need to do it at one place. I come from C# where the property grid was really useful when developing UI. Here's the same event defined here: Hope this help? |
|
|
||
| ## Emitted when object changed. | ||
| signal object_changed(object: Object) | ||
| ## Emitted when propterty changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ## Emitted when propterty changed. | |
| ## Emitted when property changed. |
|
|
||
| update_inspector() | ||
|
|
||
| func emit_object_changed(object: Object, propertyName: StringName) -> void: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func emit_object_changed(object: Object, propertyName: StringName) -> void: | |
| func emit_object_changed(object: Object, property_name: StringName) -> void: |
|
Can you attach a minimal demo project? I am currently working on version |
This feature is really useful when you want to do certain updates based on a value changed.