any signal or method to implement to catch when a property in inspector is changed ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By skeleton60

Hello,

in unity, there is a validate() method called everytime i property is changed in inspector

is there something like this for godot ?

i have a tool script that need to update things when the transform (position or rotation or scale) of a node2d is changed (and i would like in general to catch any change in inspector to update my scene for a tool script !)

i dont see any notification event happening when i change some variables

i cant find signals for this

i cant make setget method (or can i?) because its about catching any change in the transform of a node2d

Thanks for help

I haven’t found any signals for your use, but this might help: https://forum.godotengine.org/92739/check-if-variable-is-changed

TheJokingJack | 2021-09-22 21:01

:bust_in_silhouette: Reply From: decepticlown

Straight-outta-docs:

Object class    
void property_list_changed_notify()

Notify the editor that the property list has changed, so that editor plugins can take the new values into account. Does nothing on export builds.

This function is used to send a notification to the editor manually (for updating the property inspector), not a virtual function that is called automatically when any property has changed. The latter is what OP need, but it does not exist.

MintSoda | 2022-01-08 08:56

:bust_in_silhouette: Reply From: MintSoda

method1: Built-in node types have predefined setter and getters. Override the predefined setter, for example set_position(value) in Node2D. It will be called when even you set position in the editor, as long as you use tool keyword.

method2: Use notification. All CanvasItem has NOTIFICATION_TRANSFORM_CHANGED, capture it in _notification(what) and do things. This notification will be sent whenever and however the transform is changed (even when the transform was changed by Tween or AnimationPlayer). But you have to use tool keyword to receive it in editor.