Detect when object is dragged around in the scene editor

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Aaron
:warning: Old Version Published before Godot 3 was released.

I have an object (set to tool mode) with some variables that I want to depend on where it’s positioned in the scene editor. These variables don’t depend on where the object is positioned in general - especially when I animate the object’s position during gameplay. Just when the object is dragged around in the scene editor.

I tried overriding _notification and checking for NOTIFICATION_TRANSFORM_CHANGED, but this seems to happen for whenever anything changes the object’s position, whether it’s the editor or anything else. Using get_tree().is_editor_hint() seems to give a nil error inside _notification.

get_tree is only usable after _ready, so it might not be available during NOTIFICATION_READY. Maybe you should check for is_editor_hint only after you are sure it is NOTIFICATION_TRANSFORM_CHANGED? Also, try doing get_tree() != null too.

Bojidar Marinov | 2016-03-14 16:16

:bust_in_silhouette: Reply From: Aaron

The answer is CanvasItem.edit_set_state. Overriding edit_set_state lets me update the variables that depend on the node’s position when it’s moved in the editor.

edit_set_state doesn’t seem to exist in the current docs. Has anyone figured out the solution for the current version (3.5) of Godot?

Atlinx | 2022-08-29 03:44