Open angedelamort opened 6 months ago
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 InspectorProperty
?
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: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.propertygrid.propertyvaluechanged?view=windowsdesktop-8.0
Hope this help?
Can you attach a minimal demo project? I am currently working on version 2.0
and need to look into your suggestion in more detail.
This feature is really useful when you want to do certain updates based on a value changed.